mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Use correct matrix for patterns with showText.
We were incorrectly using the transform in the pattern before it had been adjusted causing the pattern to be misplaced relative to the page. Fixes: ShowText-ShadingPattern.pdf (already in corpus) Fixes: #8111 Fixes: #9243
This commit is contained in:
parent
c2f335186a
commit
1c7048399b
6 changed files with 134 additions and 11 deletions
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue