diff --git a/src/core/fonts.js b/src/core/fonts.js index 677e29386..b173e02eb 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -2475,6 +2475,12 @@ var Font = (function FontClosure() { for (var code in GlyphMapForStandardFonts) { map[+code] = GlyphMapForStandardFonts[code]; } + var isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap; + if (!isIdentityUnicode) { + this.toUnicode.forEach(function(charCode, unicodeCharCode) { + map[+charCode] = unicodeCharCode; + }); + } this.toFontChar = map; this.toUnicode = new ToUnicodeMap(map); } else if (/Symbol/i.test(fontName)) { diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 8edc0bd67..2e34a2b7c 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -59,6 +59,7 @@ !bug864847.pdf !issue1002.pdf !issue925.pdf +!issue2840.pdf !issue4668.pdf !issue5039.pdf !issue5070.pdf diff --git a/test/pdfs/issue2840.pdf b/test/pdfs/issue2840.pdf new file mode 100644 index 000000000..b623fe7da --- /dev/null +++ b/test/pdfs/issue2840.pdf @@ -0,0 +1,128 @@ +%PDF-1.7 +28 0 obj +<< +/Type /Catalog +/Pages 29 0 R +>> +endobj +29 0 obj +<< +/Type /Pages +/MediaBox [ 0 0 200 50 ] +/Count 1 +/Kids [ 30 0 R ] +>> +endobj +30 0 obj +<< +/Type /Page +/Parent 29 0 R +/Resources << +/Font << +/F1 31 0 R +>> + +>> + +/Contents 32 0 R +>> +endobj +31 0 obj +<< +/Type /Font +/Subtype /Type0 +/BaseFont /Arial,Bold +/Encoding /Identity-H +/DescendantFonts [ 13 0 R ] +/ToUnicode 11 0 R +>> +endobj +32 0 obj +<< +/Length 79 +>> +stream +BT +10 20 TD +/F1 20 Tf +<024702680266025F026A00030269026802650262026B025A> Tj +ET +endstream +endobj +13 0 obj +<< +/Type /Font +/Subtype /CIDFontType2 +/BaseFont /Arial,Bold +/CIDSystemInfo 12 0 R +/FontDescriptor 10 0 R +/W [ 587 [ 722 ] 588 [ 611 ] 586 [ 667 ] 570 [ 722 ] 591 [ 667 ] 584 [ 778 ] 572 [ 722 ] 583 [ 722 ] 578 [ 719 ] 601 [ 719 ] 3 [ 278 ] 582 [ 833 ] 575 [ 667 ] 574 [ 712 ] 592 [ 730 ] 580 [ 610 ] 597 [ 979 ] 585 [ 719 ] 581 [ 702 ] 195 [ 278 ] 577 [ 626 ] 576 [ 904 ] 600 [ 1031 ] 595 [ 1019 ] 573 [ 567 ] 11 [ 333 ] 571 [ 719 ] 579 [ 719 ] 12 [ 333 ] 616 [ 611 ] 614 [ 740 ] 607 [ 556 ] 618 [ 611 ] 617 [ 604 ] 613 [ 635 ] 610 [ 615 ] 619 [ 556 ] 602 [ 556 ] 46 [ 722 ] 53 [ 722 ] 56 [ 722 ] 38 [ 722 ] 43 [ 722 ] 40 [ 667 ] 49 [ 722 ] 50 [ 778 ] 15 [ 278 ] 39 [ 722 ] 48 [ 833 ] 44 [ 278 ] 55 [ 611 ] 60 [ 667 ] 620 [ 490 ] 623 [ 556 ] 604 [ 615 ] 630 [ 615 ] 18 [ 278 ] 615 [ 604 ] 629 [ 854 ] 611 [ 615 ] 51 [ 667 ] 82 [ 611 ] 79 [ 278 ] 76 [ 278 ] 70 [ 556 ] 92 [ 556 ] 75 [ 611 ] 71 [ 611 ] 72 [ 556 ] 85 [ 389 ] 81 [ 611 ] 86 [ 556 ] 88 [ 611 ] 83 [ 611 ] 633 [ 583 ] 42 [ 778 ] 74 [ 611 ] 68 [ 556 ] 47 [ 611 ] 80 [ 889 ] 87 [ 333 ] 612 [ 500 ] 609 [ 497 ] 606 [ 635 ] 73 [ 333 ] 77 [ 278 ] 36 [ 722 ] 19 [ 556 ] 22 [ 556 ] 17 [ 278 ] 21 [ 556 ] 20 [ 556 ] 608 [ 709 ] 621 [ 556 ] 28 [ 556 ] 23 [ 556 ] 27 [ 556 ] 24 [ 556 ] 7 [ 556 ] 37 [ 722 ] 54 [ 667 ] 16 [ 333 ] 624 [ 615 ] 9 [ 722 ] 91 [ 556 ] 625 [ 581 ] 69 [ 611 ] 603 [ 618 ] 626 [ 833 ] 78 [ 556 ] 89 [ 556 ] 605 [ 417 ] 29 [ 333 ] 26 [ 556 ] 25 [ 556 ] 622 [ 875 ] 35 [ 975 ] 30 [ 333 ] 90 [ 778 ] 598 [ 719 ] 589 [ 622 ] 14 [ 584 ] ] +>> +endobj +11 0 obj +<< +/Length 929 +/Filter /FlateDecode +/Length1 2189 +>> +stream +x]VnH ?3$@0`1dvXUC# ]ݣ4oi0^q۴y\.7~w!re<Nzݬezo>]h3 ?>7~l~=>/[.a|alV~eE<60trܝݍ<"-Ur15Lv?SxO0YWx-hY0UX$m%- W,WivKz+iqςB#4@]6zVT毒I[#Nt-ض~#X7)I4fےhj@jU۰EcH96LX<&ٚ);5&l՜\idvS ;ՋJYu +eSU+C  +!`V6 Ti,|P U9VI62h.2W1SJ4 -Bβ[Qг|a\@MA*a+)!v,L@U%w T0z>^y9+BqCpՉQ7a maeRNJ 5Ru) + dzqIydNSGPD~C akRt%`Wڪ^%8J0aV!Kٴ솅 e+\IÆҨl'JlM  +x;\JmwW f2֜q$~,[x6S7:+J`C%g;YReE%lŜ^q'U\e g<+'Bh,Ձ [m(."Iw}3`endstream +endobj +12 0 obj +<< +/Registry (Adobe) +/Ordering (Identity) +/Supplement 0 +>> +endobj +10 0 obj +<< +/Type /FontDescriptor +/FontName /Arial,Bold +/FontFamily /Arial,Bold +/Flags 32 +/FontBBox [ -628 -376 2000 1010 ] +/ItalicAngle 0 +/Ascent 728 +/Descent -210 +/Leading 117 +/CapHeight 1117 +/StemV 166 +/AvgWidth 479 +/MxWidth 2628 +/MissingWidth 479 +>> +endobj +xref +0 1 +0000000000 65535 f +10 1 +0000003141 00000 n +11 1 +0000002051 00000 n +12 1 +0000003066 00000 n +13 1 +0000000523 00000 n +28 1 +0000000009 00000 n +29 1 +0000000060 00000 n +30 1 +0000000146 00000 n +31 1 +0000000254 00000 n +32 1 +0000000394 00000 n +trailer +<< +/Size 9 +/Root 28 0 R +>> +startxref +3402 +%%EOF \ No newline at end of file diff --git a/test/test_manifest.json b/test/test_manifest.json index 65c145d65..45de838d2 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -746,6 +746,13 @@ "type": "eq", "about": "Seac with differences array that messes up mapping." }, + { "id": "issue2840", + "file": "pdfs/issue2840.pdf", + "md5": "d9df49f6d62668d099e0fb7e74f8f337", + "rounds": 1, + "link": false, + "type": "eq" + }, { "id": "bug866395", "file": "pdfs/bug866395.pdf", "md5": "f03bc77e84637241980b09a0a220f575",