mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 06:38:07 +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;
|
continue;
|
||||||
}
|
}
|
||||||
|
case OPS.setTextMatrix:
|
||||||
|
operatorList.addOp(fn, [new Float32Array(args)]);
|
||||||
|
continue;
|
||||||
case OPS.markPoint:
|
case OPS.markPoint:
|
||||||
case OPS.markPointProps:
|
case OPS.markPointProps:
|
||||||
case OPS.beginCompat:
|
case OPS.beginCompat:
|
||||||
|
|
|
@ -787,6 +787,9 @@ class OperatorList {
|
||||||
transfers.push(bbox.buffer);
|
transfers.push(bbox.buffer);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case OPS.setTextMatrix:
|
||||||
|
transfers.push(argsArray[i][0].buffer);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return transfers;
|
return transfers;
|
||||||
|
|
|
@ -17,7 +17,6 @@ import {
|
||||||
DrawOPS,
|
DrawOPS,
|
||||||
FeatureTest,
|
FeatureTest,
|
||||||
FONT_IDENTITY_MATRIX,
|
FONT_IDENTITY_MATRIX,
|
||||||
IDENTITY_MATRIX,
|
|
||||||
ImageKind,
|
ImageKind,
|
||||||
info,
|
info,
|
||||||
OPS,
|
OPS,
|
||||||
|
@ -311,7 +310,7 @@ class CanvasExtraState {
|
||||||
|
|
||||||
fontSizeScale = 1;
|
fontSizeScale = 1;
|
||||||
|
|
||||||
textMatrix = IDENTITY_MATRIX;
|
textMatrix = null;
|
||||||
|
|
||||||
textMatrixScale = 1;
|
textMatrixScale = 1;
|
||||||
|
|
||||||
|
@ -1611,7 +1610,7 @@ class CanvasGraphics {
|
||||||
|
|
||||||
// Text
|
// Text
|
||||||
beginText() {
|
beginText() {
|
||||||
this.current.textMatrix = IDENTITY_MATRIX;
|
this.current.textMatrix = null;
|
||||||
this.current.textMatrixScale = 1;
|
this.current.textMatrixScale = 1;
|
||||||
this.current.x = this.current.lineX = 0;
|
this.current.x = this.current.lineX = 0;
|
||||||
this.current.y = this.current.lineY = 0;
|
this.current.y = this.current.lineY = 0;
|
||||||
|
@ -1732,12 +1731,13 @@ class CanvasGraphics {
|
||||||
this.moveText(x, y);
|
this.moveText(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
setTextMatrix(a, b, c, d, e, f) {
|
setTextMatrix(matrix) {
|
||||||
this.current.textMatrix = [a, b, c, d, e, f];
|
const { current } = this;
|
||||||
this.current.textMatrixScale = Math.hypot(a, b);
|
current.textMatrix = matrix;
|
||||||
|
current.textMatrixScale = Math.hypot(matrix[0], matrix[1]);
|
||||||
|
|
||||||
this.current.x = this.current.lineX = 0;
|
current.x = current.lineX = 0;
|
||||||
this.current.y = this.current.lineY = 0;
|
current.y = current.lineY = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
nextLine() {
|
nextLine() {
|
||||||
|
@ -1904,7 +1904,9 @@ class CanvasGraphics {
|
||||||
!current.patternFill;
|
!current.patternFill;
|
||||||
|
|
||||||
ctx.save();
|
ctx.save();
|
||||||
ctx.transform(...current.textMatrix);
|
if (current.textMatrix) {
|
||||||
|
ctx.transform(...current.textMatrix);
|
||||||
|
}
|
||||||
ctx.translate(current.x, current.y + current.textRise);
|
ctx.translate(current.x, current.y + current.textRise);
|
||||||
|
|
||||||
if (fontDirection > 0) {
|
if (fontDirection > 0) {
|
||||||
|
@ -2099,7 +2101,9 @@ class CanvasGraphics {
|
||||||
this._cachedGetSinglePixelWidth = null;
|
this._cachedGetSinglePixelWidth = null;
|
||||||
|
|
||||||
ctx.save();
|
ctx.save();
|
||||||
ctx.transform(...current.textMatrix);
|
if (current.textMatrix) {
|
||||||
|
ctx.transform(...current.textMatrix);
|
||||||
|
}
|
||||||
ctx.translate(current.x, current.y + current.textRise);
|
ctx.translate(current.x, current.y + current.textRise);
|
||||||
|
|
||||||
ctx.scale(textHScale, fontDirection);
|
ctx.scale(textHScale, fontDirection);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue