Merge pull request #10850 from brendandahl/scale-line-width

Scale stroking line width when using a tiling pattern.
This commit is contained in:
Tim van der Meij 2019-07-12 22:50:32 +02:00 committed by GitHub
commit 87f36e3520
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 3 deletions

View File

@ -1145,9 +1145,6 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
consumePath = typeof consumePath !== 'undefined' ? consumePath : true; consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
var ctx = this.ctx; var ctx = this.ctx;
var strokeColor = this.current.strokeColor; 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 // For stroke we want to temporarily change the global alpha to the
// stroking alpha. // stroking alpha.
ctx.globalAlpha = this.current.strokeAlpha; ctx.globalAlpha = this.current.strokeAlpha;
@ -1156,10 +1153,21 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
// for patterns, we transform to pattern space, calculate // for patterns, we transform to pattern space, calculate
// the pattern, call stroke, and restore to user space // the pattern, call stroke, and restore to user space
ctx.save(); 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.strokeStyle = strokeColor.getPattern(ctx, this);
ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR,
this.current.lineWidth * scale);
ctx.stroke(); ctx.stroke();
ctx.restore(); ctx.restore();
} else { } 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(); ctx.stroke();
} }
if (consumePath) { if (consumePath) {

View File

@ -139,6 +139,7 @@
!issue6413.pdf !issue6413.pdf
!issue4630.pdf !issue4630.pdf
!issue4909.pdf !issue4909.pdf
!scorecard_reduced.pdf
!issue5084.pdf !issue5084.pdf
!issue8960_reduced.pdf !issue8960_reduced.pdf
!issue5202.pdf !issue5202.pdf

Binary file not shown.

View File

@ -3483,6 +3483,12 @@
"type": "eq", "type": "eq",
"about": "A CIDFontType0 font with a CFF font that isn't actually CID." "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", { "id": "bug921409",
"file": "pdfs/bug921409.pdf", "file": "pdfs/bug921409.pdf",
"md5": "920e88dde0f5436ebe0df0281e1c30ca", "md5": "920e88dde0f5436ebe0df0281e1c30ca",