Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scale stroking line width when using a tiling pattern. #10850

Merged
merged 1 commit into from
Jul 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/display/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
timvandermeij marked this conversation as resolved.
Show resolved Hide resolved
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) {
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
!issue6413.pdf
!issue4630.pdf
!issue4909.pdf
!scorecard_reduced.pdf
!issue5084.pdf
!issue8960_reduced.pdf
!issue5202.pdf
Expand Down
Binary file added test/pdfs/scorecard_reduced.pdf
Binary file not shown.
6 changes: 6 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down