mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-23 16:48:08 +02:00
Avoid to create an array when setting the text matrix
This commit is contained in:
parent
9217d253aa
commit
4c63905a18
3 changed files with 20 additions and 10 deletions
|
@ -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:
|
||||
|
|
|
@ -787,6 +787,9 @@ class OperatorList {
|
|||
transfers.push(bbox.buffer);
|
||||
}
|
||||
break;
|
||||
case OPS.setTextMatrix:
|
||||
transfers.push(argsArray[i][0].buffer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return transfers;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue