From 446efab70774ac564f8dd3e519c9b2c7a6dbbb2c Mon Sep 17 00:00:00 2001 From: Brendan Dahl Date: Thu, 23 May 2019 16:47:22 -0700 Subject: [PATCH] Scale stroking line width when using a tiling pattern. --- src/display/canvas.js | 14 +++++++++++--- test/pdfs/.gitignore | 1 + test/pdfs/scorecard_reduced.pdf | Bin 0 -> 6975 bytes test/test_manifest.json | 6 ++++++ 4 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 test/pdfs/scorecard_reduced.pdf diff --git a/src/display/canvas.js b/src/display/canvas.js index dc399ef35..3f04a2960 100644 --- a/src/display/canvas.js +++ b/src/display/canvas.js @@ -1145,9 +1145,6 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { consumePath = typeof consumePath !== 'undefined' ? consumePath : true; var ctx = this.ctx; var strokeColor = this.current.strokeColor; - // Prevent drawing too thin lines by enforcing a minimum line width. - ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, - this.current.lineWidth); // For stroke we want to temporarily change the global alpha to the // stroking alpha. ctx.globalAlpha = this.current.strokeAlpha; @@ -1156,10 +1153,21 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { // for patterns, we transform to pattern space, calculate // the pattern, call stroke, and restore to user space ctx.save(); + // The current transform will be replaced while building the pattern, + // but the line width needs to be adjusted by the current transform, so + // we must scale it. To properly fix this we should be using a pattern + // transform instead (see #10955). + let transform = ctx.mozCurrentTransform; + const scale = Util.singularValueDecompose2dScale(transform)[0]; ctx.strokeStyle = strokeColor.getPattern(ctx, this); + ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, + this.current.lineWidth * scale); ctx.stroke(); ctx.restore(); } else { + // Prevent drawing too thin lines by enforcing a minimum line width. + ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, + this.current.lineWidth); ctx.stroke(); } if (consumePath) { diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index b704c9682..1f0888ab1 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -138,6 +138,7 @@ !issue6413.pdf !issue4630.pdf !issue4909.pdf +!scorecard_reduced.pdf !issue5084.pdf !issue8960_reduced.pdf !issue5202.pdf diff --git a/test/pdfs/scorecard_reduced.pdf b/test/pdfs/scorecard_reduced.pdf new file mode 100644 index 0000000000000000000000000000000000000000..597c3247cce357005c21526ebd0f19139accdc40 GIT binary patch literal 6975 zcmeHMdsGuw8V5m9Xp|}x%a!@<9C1e zyRQI6cq9uA<}(5suAjfi@DxA@M5@yn5(ylwGZL6tmrLLf3P(eHk$?xsLLxW}b4h|3j0D2JOOl`;q;POE@^=V72+r;%_%L*j%2GaD?xq>R*O8jKc* z3oFb7uG3JY8A91oDIBTOQ-m3g)MFH3Zvsb!Crd=({77LKS0+H&GOmm-j0_Fq3M07O zNOmZP&l4h22{)V31y& z@qv5sa5P~|qozYVn=e^(peP(qk`yGgRVx875GsTda!drA6i;a3smUnBhERZjg)$SE zf#Es5R;|XpRVuZL?J@W@{yQJd@K`AHYS`Xya8U6(4GRXj4H;cRE%S35eeuIGL%VCA z*Ibq^_qami=g{Cl(n4Wo%4#OG41^I75D^>c#Fl|}>9O8Wg80JDQ24MC;_$oqr&6g1 zmFnqP7k9mfAL8oe<}rBb(8a_3rf^K?gg|8Na@U8S4fpdI+ea4(#rNxvxEw8Z|E8yh zG$sz($O#I=F$#lF8%_!=jj%vG+q(@b8K~2fX-=MqoNZ;Kks^$g1ws*91DTmLg^|`| z`b!{ULwuB-0?Pq2upXs=LZGF?P&{EFGtC;p!70+LG+`QoCYTa|6&MA$WCW~oyn%8B z0?2DKsX!fXQt*HdrvT$1#NN$xEKa{|K01Q#1$hU5(5`?_T9j9?%d-UWmOXA;-1bra zxwQ4yMKh!BT{yH-FNfZ~P`6_b9_Y>p>wn9DM|q3FB&I2=epypq%Dl@7$tf;?CKa!& zx>i{@*uSq!#g&u(V(zaY$A>kSRnI7IJ0oi{x>whSHa{iAqkPA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/test/test_manifest.json @@ -3474,6 +3474,12 @@ "type": "eq", "about": "A CIDFontType0 font with a CFF font that isn't actually CID." }, + { "id": "scorecard_reduced", + "file": "pdfs/scorecard_reduced.pdf", + "md5": "aa8ed0827092c963eea64adb718a3806", + "rounds": 1, + "type": "eq" + }, { "id": "bug921409", "file": "pdfs/bug921409.pdf", "md5": "920e88dde0f5436ebe0df0281e1c30ca",