Skip to content

Commit

Permalink
Enforce linewidth to 1px when at least one of scale factor is lower t…
Browse files Browse the repository at this point in the history
…han 1
  • Loading branch information
calixteman committed Jan 15, 2021
1 parent 6619f1f commit 3886e66
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/display/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -2668,11 +2668,16 @@ const CanvasGraphics = (function CanvasGraphicsClosure() {
const sqDet = (m[0] * m[3] - m[2] * m[1]) ** 2;
const sqNorm1 = m[0] ** 2 + m[2] ** 2;
const sqNorm2 = m[1] ** 2 + m[3] ** 2;
if (sqNorm1 !== sqNorm2 && sqNorm1 > sqDet && sqNorm2 > sqDet) {
// The parallelogramm isn't a losange and both heights
// are lower than 1 so the resulting line width must be 1
if (sqNorm1 !== sqNorm2 && (sqNorm1 > sqDet || sqNorm2 > sqDet)) {
// The parallelogram isn't a losange and at least one height
// is lower than 1 so the resulting line width must be 1
// but it cannot be achieved with one scale: when scaling a pixel
// we'll get a rectangle (see isssue #12295).
// For example with matrix [0.001 0, 0, 100], a pixel is transformed
// in a rectangle 0.001x100. If we just scale by 1000 (to have a 1)
// then we'll get a rectangle 1x1e5 which is wrong.
// In this case, we must reset the transform and set linewidth to 1
// and then stroke.
this._cachedGetSinglePixelWidth = -1;
} else if (sqDet > Number.EPSILON ** 2) {
// The multiplication by the constant 1.000001 is here to have
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
!issue11045.pdf
!bug1057544.pdf
!issue11150_reduced.pdf
!issue6127.pdf
!issue11242_reduced.pdf
!issue11279.pdf
!issue11362.pdf
Expand Down
Binary file added test/pdfs/issue6127.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 @@ -4863,6 +4863,12 @@
"107R": {
"value": false
},
{ "id": "issue6127",
"file": "pdfs/issue6127.pdf",
"md5": "65ef9572bddef5fddfaf7172f10a0df2",
"rounds": 1,
"type": "eq"
},
"108R": {
"value": true
},
Expand Down

0 comments on commit 3886e66

Please sign in to comment.