From 2600e59acba505fdadc03fdd044d873de16852c8 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 14 Jan 2021 15:34:44 +0100 Subject: [PATCH] Always re-measure non-embedded ArialNarrow fonts (bug 1671312, PR 12725 follow-up) While PR 12725 fixed bug 1671312 as reported, i.e. the "In the upper right corner "Purposes' has bad kerning."-part, it however broke other parts of the text rendering. Note in particular the tables, e.g. on page 2 and beyond, where the glyphs are now rendered too close together. The reason for this is that the fonts in question are non-embedded ArialNarrow, which we just replace with Helvetica which obviously is not narrow. Given that the font replacement isn't a perfect fit for non-embedded ArialNarrow, we still need to re-measure the glyph widths in this case. --- src/core/fonts.js | 7 ++++++- test/pdfs/.gitignore | 1 + test/pdfs/bug1671312_ArialNarrow.pdf | Bin 0 -> 1913 bytes test/test_manifest.json | 6 ++++++ 4 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 test/pdfs/bug1671312_ArialNarrow.pdf diff --git a/src/core/fonts.js b/src/core/fonts.js index d3cfc11aa4d34..9db048959ee9c 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -1335,8 +1335,13 @@ var Font = (function FontClosure() { // name ArialBlack for example will be replaced by Helvetica. this.black = name.search(/Black/g) !== -1; + // Use 'name' instead of 'fontName' here because the original + // name ArialNarrow for example will be replaced by Helvetica. + const isNarrow = name.search(/Narrow/g) !== -1; + // if at least one width is present, remeasure all chars when exists - this.remeasure = !isStandardFont && Object.keys(this.widths).length > 0; + this.remeasure = + (!isStandardFont || isNarrow) && Object.keys(this.widths).length > 0; if ( (isStandardFont || isMappedToStandardFont) && type === "CIDFontType2" && diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index a827ae72c02a4..7dae93a0faf50 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -366,6 +366,7 @@ !issue6889.pdf !bug1001080.pdf !bug1671312_reduced.pdf +!bug1671312_ArialNarrow.pdf !issue6108.pdf !issue6113.pdf !openoffice.pdf diff --git a/test/pdfs/bug1671312_ArialNarrow.pdf b/test/pdfs/bug1671312_ArialNarrow.pdf new file mode 100644 index 0000000000000000000000000000000000000000..ee887b3c484372e03bb85f3a708b09736de5ba1e GIT binary patch literal 1913 zcma)7%}(1u5WeqI%mt}EP_Ng2iG+}nKt$C-5k#dD>S0MXW>K(_?X=LB?4fVazDU1W zdo2@zgq6*#XJ_X7W_B{!J3pH5haWPr_xIoLKO!Va<;@+5g98!F%c42c_lAN=W%cGv zS5^5_1ecAu|4L~pg3m^;Y>`tKDG^NSr70R3E9~bRo!7+LZzsm)w++Q<2$LWAm0dNr z6s0&iGOfqH3Z)1>HhN>1lOo?3!YhNEIFM8Q*gB1(NCc<0t^wIm#1)iVNGZcqRUY zsmpD(1l#`Vx?M;KqjGqB09`Z)S5xY=0|r9^?9vmM+p2D6x4LpS`n;0F9fRVueKLB)Eha^6y+Q<2T^n}aZK&-{<1T4YZ4FlhouxZOl_Uaz&@?C??wi~iC8(;T zI8l^Am&6%`X-X;$-HPOx;tcO>&$`Z!?ccI`d&J;4ZowBF=&%?s8G{2a-h)dTEBDU6 zv5cLbvC=U*0Cw&iw%*SB`4}1J#Id?~o&(Eh)aJ^$^!$P0_YSkmEd(Af=D?Eiy`7gX z4$gZ&<_nJOCMA{_?KSo-~2eRuI(jA0EJ6L~XFCvnDkxcldN zFm9)F{la;ozOE;rcV`)D>iKm#@6WaKi~ali@%Plp5&F&Fbv@wEJg%2s|B`e#FJW*`a9sI(m=31}kCJ{`d^San5ub!? zQ8$&*_hPybn954h;s^s9g~x6!-c6PmSan%F(ONI<#x~Z}?`d%-ju(Ola_dcgHa}Ko zEhJ?E)4h8rO_C^~HTAj>ql+IZdY#HJJ9l)E!i?R~#S)3^=s5b0E==V>*HqeWOeNgd hy(r6u_#Xrl@zVY>;OdH?tHzNJGdU7_d&ghq;y<#px-9?z literal 0 HcmV?d00001 diff --git a/test/test_manifest.json b/test/test_manifest.json index abe1a6d30d0bb..5c00673ce78ff 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -2301,6 +2301,12 @@ "rounds": 1, "type": "eq" }, + { "id": "bug1671312_ArialNarrow", + "file": "pdfs/bug1671312_ArialNarrow.pdf", + "md5": "f4f0a0d1dc9276bd6e3402165ecdc3d7", + "rounds": 1, + "type": "eq" + }, { "id": "issue7020", "file": "pdfs/issue7020.pdf", "md5": "93b464e21c649e64ae92eeafe99fc31b",