From fef24658e7e0d993ce3fd3c03e2ce7473b376dc2 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 30 Jun 2020 12:18:06 +0200 Subject: [PATCH] Adjust the heuristics used when dealing with rectangles, i.e. `re` operators, with zero width/height (issue 12010) --- src/display/canvas.js | 16 ++++++++-------- test/pdfs/.gitignore | 1 + test/pdfs/issue12010_reduced.pdf | Bin 0 -> 795 bytes test/test_manifest.json | 6 ++++++ 4 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 test/pdfs/issue12010_reduced.pdf diff --git a/src/display/canvas.js b/src/display/canvas.js index bdfb16f40..d3f783dab 100644 --- a/src/display/canvas.js +++ b/src/display/canvas.js @@ -1185,20 +1185,20 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { y = args[j++]; var width = args[j++]; var height = args[j++]; - if (width === 0) { + if (width === 0 && ctx.lineWidth < this.getSinglePixelWidth()) { width = this.getSinglePixelWidth(); } - if (height === 0) { + if (height === 0 && ctx.lineWidth < this.getSinglePixelWidth()) { height = this.getSinglePixelWidth(); } var xw = x + width; var yh = y + height; - this.ctx.moveTo(x, y); - this.ctx.lineTo(xw, y); - this.ctx.lineTo(xw, yh); - this.ctx.lineTo(x, yh); - this.ctx.lineTo(x, y); - this.ctx.closePath(); + ctx.moveTo(x, y); + ctx.lineTo(xw, y); + ctx.lineTo(xw, yh); + ctx.lineTo(x, yh); + ctx.lineTo(x, y); + ctx.closePath(); break; case OPS.moveTo: x = args[j++]; diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index d235d1f37..44c50058f 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -262,6 +262,7 @@ !bug903856.pdf !bug850854.pdf !bug866395.pdf +!issue12010_reduced.pdf !issue11718_reduced.pdf !bug1027533.pdf !bug1028735.pdf diff --git a/test/pdfs/issue12010_reduced.pdf b/test/pdfs/issue12010_reduced.pdf new file mode 100644 index 0000000000000000000000000000000000000000..7294c93b33674e48b34c1deba8498c9032030553 GIT binary patch literal 795 zcmah{&ubGw7>$I0Oo@0Zf+$~wcyo6rv(xNC2Z zr^U#=kqk5FyGG+4vfE-eRe+DFnVY<@$1|}jH+4^H__;fyWXwpeYiDk>P^$EA2Fo+% zEj~@XQCF2N4RTBXA`#gH4NOi9kR%V_ePtUHBPyR=p;EfkB74+qxyPuG{;y;!)i`s^d$ zixbA!tM0kQ_us0eRe$hi@MPn|#y(u_9z44I^dOFsDB3GT-{1aN+?W2+#qG2B?w1QM z2hB49E_{A{DJ`3PX5I3nCX$bk12yCv9ayH6P#BeuFsvVG4rqm(=KH6yns*ArRL|l> zEx~#}PGUr-oMTF|WX$Ds`+7p?ZI~svl8ywJ-O{