diff --git a/src/core/evaluator.js b/src/core/evaluator.js index b7e2e5136..c0410288c 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -2237,6 +2237,9 @@ class PartialEvaluator { } continue; } + case OPS.setTextMatrix: + operatorList.addOp(fn, [new Float32Array(args)]); + continue; case OPS.markPoint: case OPS.markPointProps: case OPS.beginCompat: diff --git a/src/core/operator_list.js b/src/core/operator_list.js index 389ca1eb7..5b1885ef9 100644 --- a/src/core/operator_list.js +++ b/src/core/operator_list.js @@ -787,6 +787,9 @@ class OperatorList { transfers.push(bbox.buffer); } break; + case OPS.setTextMatrix: + transfers.push(argsArray[i][0].buffer); + break; } } return transfers; diff --git a/src/display/canvas.js b/src/display/canvas.js index 7bd1e15cd..fd560ddd4 100644 --- a/src/display/canvas.js +++ b/src/display/canvas.js @@ -17,7 +17,6 @@ import { DrawOPS, FeatureTest, FONT_IDENTITY_MATRIX, - IDENTITY_MATRIX, ImageKind, info, OPS, @@ -311,7 +310,7 @@ class CanvasExtraState { fontSizeScale = 1; - textMatrix = IDENTITY_MATRIX; + textMatrix = null; textMatrixScale = 1; @@ -1611,7 +1610,7 @@ class CanvasGraphics { // Text beginText() { - this.current.textMatrix = IDENTITY_MATRIX; + this.current.textMatrix = null; this.current.textMatrixScale = 1; this.current.x = this.current.lineX = 0; this.current.y = this.current.lineY = 0; @@ -1732,12 +1731,13 @@ class CanvasGraphics { this.moveText(x, y); } - setTextMatrix(a, b, c, d, e, f) { - this.current.textMatrix = [a, b, c, d, e, f]; - this.current.textMatrixScale = Math.hypot(a, b); + setTextMatrix(matrix) { + const { current } = this; + current.textMatrix = matrix; + current.textMatrixScale = Math.hypot(matrix[0], matrix[1]); - this.current.x = this.current.lineX = 0; - this.current.y = this.current.lineY = 0; + current.x = current.lineX = 0; + current.y = current.lineY = 0; } nextLine() { @@ -1904,7 +1904,9 @@ class CanvasGraphics { !current.patternFill; ctx.save(); - ctx.transform(...current.textMatrix); + if (current.textMatrix) { + ctx.transform(...current.textMatrix); + } ctx.translate(current.x, current.y + current.textRise); if (fontDirection > 0) { @@ -2099,7 +2101,9 @@ class CanvasGraphics { this._cachedGetSinglePixelWidth = null; ctx.save(); - ctx.transform(...current.textMatrix); + if (current.textMatrix) { + ctx.transform(...current.textMatrix); + } ctx.translate(current.x, current.y + current.textRise); ctx.scale(textHScale, fontDirection);