Enforce linewidth to 1px when at least one of scale factor is lower than 1

This commit is contained in:
Calixte Denizet 2021-01-15 11:56:20 +01:00
parent d9df96d299
commit 0d1b19632d
4 changed files with 34222 additions and 3 deletions

View File

@ -2667,11 +2667,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 parallelogram 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 issue #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.0000001 is here to have

View File

@ -94,6 +94,7 @@
!issue11045.pdf
!bug1057544.pdf
!issue11150_reduced.pdf
!issue6127.pdf
!issue11242_reduced.pdf
!issue11279.pdf
!issue11362.pdf

34206
test/pdfs/issue6127.pdf Normal file

File diff suppressed because one or more lines are too long

View File

@ -4877,6 +4877,13 @@
}
}
},
{ "id": "issue6127",
"file": "pdfs/issue6127.pdf",
"md5": "65ef9572bddef5fddfaf7172f10a0df2",
"rounds": 1,
"lastPage": 1,
"type": "eq"
},
{ "id": "annotation-polyline-polygon",
"file": "pdfs/annotation-polyline-polygon.pdf",
"md5": "e68611602f58c8ca70cc40575ba3b04e",