Get the right transform for a pattern before filling some text

It fixes #16091.
This commit is contained in:
Calixte Denizet 2026-04-01 12:22:50 +02:00 committed by calixteman
parent d1a711bca3
commit a1b64c52a1
No known key found for this signature in database
GPG Key ID: 0C5442631EE0691F
4 changed files with 25 additions and 17 deletions

View File

@ -2137,6 +2137,23 @@ class CanvasGraphics {
fillStrokeMode === TextRenderingMode.STROKE ||
fillStrokeMode === TextRenderingMode.FILL_STROKE;
let lineWidth = current.lineWidth;
const scale = current.textMatrixScale;
if (scale === 0 || lineWidth === 0) {
if (needsStroke) {
lineWidth = this.getSinglePixelWidth();
}
} else {
lineWidth /= scale;
}
if (fontSizeScale !== 1.0) {
ctx.scale(fontSizeScale, fontSizeScale);
lineWidth /= fontSizeScale;
}
ctx.lineWidth = lineWidth;
if (needsFill && current.patternFill) {
ctx.save();
const pattern = current.fillColor.getPattern(
@ -2165,23 +2182,6 @@ class CanvasGraphics {
ctx.strokeStyle = pattern;
}
let lineWidth = current.lineWidth;
const scale = current.textMatrixScale;
if (scale === 0 || lineWidth === 0) {
if (needsStroke) {
lineWidth = this.getSinglePixelWidth();
}
} else {
lineWidth /= scale;
}
if (fontSizeScale !== 1.0) {
ctx.scale(fontSizeScale, fontSizeScale);
lineWidth /= fontSizeScale;
}
ctx.lineWidth = lineWidth;
if (font.isInvalidPDFjsFont) {
const chars = [];
let width = 0;

View File

@ -896,3 +896,4 @@
!bug2026037.pdf
!tiling_patterns_variations.pdf
!function_based_shading.pdf
!issue16091.pdf

BIN
test/pdfs/issue16091.pdf Executable file

Binary file not shown.

View File

@ -14052,5 +14052,12 @@
"lastPage": 1144,
"rounds": 1,
"type": "eq"
},
{
"id": "issue16091",
"file": "pdfs/issue16091.pdf",
"md5": "ac6b2b69d9b3675b317708ec00aaf56c",
"rounds": 1,
"type": "eq"
}
]