From d3043167de6ff7b42215b40bd8bb1d2f6cdae7c9 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 22 Nov 2016 13:48:06 +0100 Subject: [PATCH] Correctly detect more cases of non-embedded Arial Black fonts (issue 7835) This patch adds support for non-embedded Arial Black fonts, that use a `Arial-Black...` format for the font names. Also, this patch changes `canvas.js` such that we always render Arial Black fonts with the maximum weight, which actually improves a number of existing test-cases. This should thus explain the test "failures", which are clear improvements compared with e.g. Adobe Reader. Fixes 7835. --- src/core/fonts.js | 2 +- src/core/standard_fonts.js | 4 ++ src/display/canvas.js | 4 +- test/pdfs/.gitignore | 1 + test/pdfs/issue7835.pdf | 143 +++++++++++++++++++++++++++++++++++++ test/test_manifest.json | 7 ++ 6 files changed, 157 insertions(+), 4 deletions(-) create mode 100644 test/pdfs/issue7835.pdf diff --git a/src/core/fonts.js b/src/core/fonts.js index 84a39f6a9..86b7b780a 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -674,7 +674,7 @@ var Font = (function FontClosure() { for (charCode in GlyphMapForStandardFonts) { map[+charCode] = GlyphMapForStandardFonts[charCode]; } - if (/ArialBlack/i.test(name)) { + if (/Arial-?Black/i.test(name)) { var SupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack(); for (charCode in SupplementalGlyphMapForArialBlack) { diff --git a/src/core/standard_fonts.js b/src/core/standard_fonts.js index 634627999..f3a30920d 100644 --- a/src/core/standard_fonts.js +++ b/src/core/standard_fonts.js @@ -40,6 +40,10 @@ t['ArialBlack-Bold'] = 'Helvetica-Bold'; t['ArialBlack-BoldItalic'] = 'Helvetica-BoldOblique'; t['ArialBlack-Italic'] = 'Helvetica-Oblique'; + t['Arial-Black'] = 'Helvetica'; + t['Arial-Black-Bold'] = 'Helvetica-Bold'; + t['Arial-Black-BoldItalic'] = 'Helvetica-BoldOblique'; + t['Arial-Black-Italic'] = 'Helvetica-Oblique'; t['Arial'] = 'Helvetica'; t['Arial-Bold'] = 'Helvetica-Bold'; t['Arial-BoldItalic'] = 'Helvetica-BoldOblique'; diff --git a/src/display/canvas.js b/src/display/canvas.js index 9c532b0fa..d09d15919 100644 --- a/src/display/canvas.js +++ b/src/display/canvas.js @@ -1359,9 +1359,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { } var name = fontObj.loadedName || 'sans-serif'; - var bold = fontObj.black ? (fontObj.bold ? '900' : 'bold') : - (fontObj.bold ? 'bold' : 'normal'); - + var bold = fontObj.black ? '900' : (fontObj.bold ? 'bold' : 'normal'); var italic = fontObj.italic ? 'italic' : 'normal'; var typeface = '"' + name + '", ' + fontObj.fallbackName; diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 713559550..ea96ec2e0 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -40,6 +40,7 @@ !issue7544.pdf !issue7598.pdf !issue7665.pdf +!issue7835.pdf !bad-PageLabels.pdf !filled-background.pdf !ArabicCIDTrueType.pdf diff --git a/test/pdfs/issue7835.pdf b/test/pdfs/issue7835.pdf new file mode 100644 index 000000000..33bc23046 --- /dev/null +++ b/test/pdfs/issue7835.pdf @@ -0,0 +1,143 @@ +%PDF-1.7 +%âãÏÓ +1 0 obj +<< +/Kids [2 0 R] +/Count 1 +/Type /Pages +>> +endobj +2 0 obj +<< +/Parent 1 0 R +/Resources +<< +/Font +<< +/C2_0 3 0 R +/TT0 4 0 R +>> +>> +/MediaBox [0 0 200 50] +/Type /Page +/Contents 5 0 R +>> +endobj +6 0 obj +<< +/Pages 1 0 R +/Type /Catalog +>> +endobj +3 0 obj +<< +/BaseFont /Arial-Black +/DescendantFonts 7 0 R +/Subtype /Type0 +/Encoding /Identity-H +/Type /Font +>> +endobj +4 0 obj +<< +/BaseFont /Arial-Black +/LastChar 116 +/Subtype /TrueType +/FontDescriptor 8 0 R +/Widths [333 0 0 660 0 0 0 0 0 0 0 0 0 333 0 0 0 667 0 667 0 667 0 667 0 0 333 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 833 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 333 0 0 0 0 667 0 0 0 0 0 444] +/Encoding /WinAnsiEncoding +/Type /Font +/FirstChar 32 +>> +endobj +5 0 obj +<< +/Length 76 +>> +stream +BT +/TT0 1 Tf +20 0 0 20 10 20 Tm +(Unit # : 15-173-)Tj +/C2_0 1 Tf +<0015>Tj +ET + +endstream +endobj +9 0 obj +<< +/Supplement 0 +/Ordering (Identity) +/Registry (Adobe) +>> +endobj +10 0 obj +<< +/FontName /Arial-Black +/StemV 200 +/Ascent 1083 +/Flags 4 +/FontWeight 900 +/FontFamily (Arial Black) +/XHeight 519 +/FontStretch /Normal +/Descent -307 +/ItalicAngle 0 +/FontBBox [-194 -307 1688 1083] +/Type /FontDescriptor +/CapHeight 716 +>> +endobj +11 0 obj +<< +/BaseFont /Arial-Black +/CIDSystemInfo 9 0 R +/DW 1000 +/Subtype /CIDFontType2 +/FontDescriptor 10 0 R +/W [0 [750 0] 2 4 333 5 [500 660 667] 9 [889 278] 11 12 389 13 [556 660] 15 17 333 18 [278] 19 28 667 29 30 333 31 33 660 34 [611 740] 36 39 778 40 [722 667] 42 43 833 44 [389 667 833 667 944] 49 50 833 51 [722 833 778] 54 55 722 56 [833 778] 59 60 778 61 [722 389 278 389 660 500 333] 68 72 667 73 [389] 74 75 667 76 77 333 78 [667 333] 81 84 667 85 [444 611 444 667 611 944 667 611 556 389 278 389 660] 98 100 778 101 [722] 102 104 833 105 115 667 116 119 333 120 130 667 131 [400] 132 134 667 135 [500 850 667] 138 139 800 140 [950] 141 142 333 143 [660] 145 [833 583] 147 149 660 150 151 667 152 [500 713 823 688 271] 157 158 400 159 [854] 161 [667 611 333 660 549 667 660 612] 169 170 667 172 [333] 173 174 778 175 [833] 178 [500] 180 181 500 182 183 278 184 [660 494 611 778 167 667] 190 191 333 192 194 667 195 [333 278 500] 199 [778 722 778] 202 203 722 204 207 389 208 209 833 210 [792] 211 214 833 215 225 333 226 [667 333 722 611 722 556 278 778 667 778 611 722 667] 239 240 660 241 243 400 247 248 833 249 [667 389 722 611 778 667 778] 256 257 667 258 [500 333 396 778 667 778 667 778 844 778 722 667 722 667 1028 668 667 333 667 500 667 534 833 667 833 667 858 833 667 778 444 778 444 722 611 722 444 722 625 833 667 833 667 722 556 722 556] 305 313 333 314 [500 304 524 604 436 1722] 321 [586] 323 [500] 325 [500] 327 328 500 329 [979 719 600 604] 333 334 354 335 [604 354 333 778 667 778 667 778 667 722 667 722 667 722 667 833 667 833 667 833 667 833 667 833 667 389 333 389 333 389 333 389 333 667 333 833] 371 373 667 374 [333 833 667 814 681 833 667 833 667 778 444 722 611 722 444 833 667 833 667 833 667 833 667] 398 [944 778 611 390 778 667] 406 [833 667 190 333 778 500 846 957 501 886 969 893 389] 419 420 778 421 [667 778] 423 424 722 425 426 833 427 [389 833 778 944 833 722] 433 434 833 435 437 722 438 [778 924 778 946 833 389 778 678 548 667 333 667 678 644 611 667 548 460] 456 457 667 458 [333 667 611 667 611 460 667 707 667 528 748 508 667 888 648 916 946 333] 476 478 667 479 [946 722 1004 667 796 722] 485 486 389 487 [667] 488 489 1210 490 [976 730 672 833] 494 496 778 497 [667 838 722 1086 688] 502 503 833 504 [730 804 944] 507 509 833 510 [722 778 722 672 924 778 860 804 1110 1138 1002 1082 774 796 1158 780] 526 527 667 528 [615 508 662 667 924 678] 534 535 706 536 [642 716 846 713] 540 543 667 544 [508 611 1013 667 690 662 949 962 771 909 621 667 975 624 667 676 444 667 611] 563 565 333 566 [1011 1023 676 642 611 667 555 468] 575 [944] 577 [944] 579 [944 778 611 750 278 500 667 1345 600] 592 [600 660] 594 595 600 596 [710 620] 598 641 710 642 [708 730 600] 646 649 990 650 652 600 653 [1020 1050 920 550 670 530 660 590 510 770] 664 [333] 665 667 400 668 [660 722 611 722 444 333]] +/Type /Font +>> +endobj +7 0 obj [11 0 R] +endobj +8 0 obj +<< +/FontName /Arial-Black +/StemV 200 +/Ascent 1100 +/Flags 32 +/FontWeight 900 +/FontFamily (Arial) +/XHeight 1000 +/FontStretch /Normal +/Descent -309 +/ItalicAngle 0 +/FontBBox [-194 -307 1688 1083] +/Type /FontDescriptor +/CapHeight 1000 +>> +endobj xref +0 12 +0000000000 65535 f +0000000015 00000 n +0000000074 00000 n +0000000267 00000 n +0000000386 00000 n +0000000744 00000 n +0000000216 00000 n +0000004069 00000 n +0000004094 00000 n +0000000873 00000 n +0000000949 00000 n +0000001203 00000 n +trailer + +<< +/Root 6 0 R +/Size 12 +>> +startxref +4343 +%%EOF diff --git a/test/test_manifest.json b/test/test_manifest.json index e877ae352..eebc90ff7 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -1812,6 +1812,13 @@ "link": false, "type": "eq" }, + { "id": "issue7835", + "file": "pdfs/issue7835.pdf", + "md5": "afb3206a83ee3fd19f3dea0480f942ec", + "rounds": 1, + "link": false, + "type": "eq" + }, { "id": "issue5972", "file": "pdfs/issue5972.pdf", "md5": "51f03e1d38410b04c9dda7e75fe8a0a3",