1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Merge pull request #14232 from brendandahl/show-text-pattern

Use correct matrix for patterns with showText.
This commit is contained in:
Jonas Jenwald 2021-11-05 10:04:56 +01:00 committed by GitHub
commit 8222d6530b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 134 additions and 11 deletions

View file

@ -2146,10 +2146,17 @@ class CanvasGraphics {
!current.patternFill;
ctx.save();
ctx.transform.apply(ctx, current.textMatrix);
ctx.translate(current.x, current.y + current.textRise);
if (fontDirection > 0) {
ctx.scale(textHScale, -1);
} else {
ctx.scale(textHScale, 1);
}
let patternTransform;
if (current.patternFill) {
// TODO: Patterns are not applied correctly to text if a non-embedded
// font is used. E.g. issue 8111 and ShowText-ShadingPattern.pdf.
ctx.save();
const pattern = current.fillColor.getPattern(
ctx,
@ -2160,14 +2167,6 @@ class CanvasGraphics {
ctx.restore();
ctx.fillStyle = pattern;
}
ctx.transform.apply(ctx, current.textMatrix);
ctx.translate(current.x, current.y + current.textRise);
if (fontDirection > 0) {
ctx.scale(textHScale, -1);
} else {
ctx.scale(textHScale, 1);
}
let lineWidth = current.lineWidth;
let resetLineWidthToOne = false;

View file

@ -112,7 +112,7 @@ class RadialAxialShadingPattern extends BaseShadingPattern {
tmpCtx.fillStyle = this._createGradient(tmpCtx);
tmpCtx.fill();
pattern = ctx.createPattern(tmpCanvas.canvas, "repeat");
pattern = ctx.createPattern(tmpCanvas.canvas, "no-repeat");
this.cachedCanvasPatterns.set(this, pattern);
}
} else {