diff --git a/src/display/canvas.js b/src/display/canvas.js index 44544baf6..aad6f94df 100644 --- a/src/display/canvas.js +++ b/src/display/canvas.js @@ -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; diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 5dd5fd73c..598cf869e 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -896,3 +896,4 @@ !bug2026037.pdf !tiling_patterns_variations.pdf !function_based_shading.pdf +!issue16091.pdf diff --git a/test/pdfs/issue16091.pdf b/test/pdfs/issue16091.pdf new file mode 100755 index 000000000..20adcf07c Binary files /dev/null and b/test/pdfs/issue16091.pdf differ diff --git a/test/test_manifest.json b/test/test_manifest.json index 70782ca2b..d10f84fe4 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -14052,5 +14052,12 @@ "lastPage": 1144, "rounds": 1, "type": "eq" + }, + { + "id": "issue16091", + "file": "pdfs/issue16091.pdf", + "md5": "ac6b2b69d9b3675b317708ec00aaf56c", + "rounds": 1, + "type": "eq" } ]