diff --git a/src/core/fonts.js b/src/core/fonts.js index edb642be4..cd8c954f4 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -1203,10 +1203,10 @@ var Font = (function FontClosure() { this.remeasure = Object.keys(this.widths).length > 0; if (isStandardFont && type === 'CIDFontType2' && this.cidEncoding.startsWith('Identity-')) { - var GlyphMapForStandardFonts = getGlyphMapForStandardFonts(); + const GlyphMapForStandardFonts = getGlyphMapForStandardFonts(); // Standard fonts might be embedded as CID font without glyph mapping. // Building one based on GlyphMapForStandardFonts. - var map = []; + const map = []; for (charCode in GlyphMapForStandardFonts) { map[+charCode] = GlyphMapForStandardFonts[charCode]; } @@ -1247,7 +1247,8 @@ var Font = (function FontClosure() { getGlyphsUnicode(), this.differences); } else { - var glyphsUnicodeMap = getGlyphsUnicode(); + const glyphsUnicodeMap = getGlyphsUnicode(); + const map = []; this.toUnicode.forEach((charCode, unicodeCharCode) => { if (!this.composite) { var glyphName = (this.differences[charCode] || @@ -1257,8 +1258,20 @@ var Font = (function FontClosure() { unicodeCharCode = unicode; } } - this.toFontChar[charCode] = unicodeCharCode; + map[+charCode] = unicodeCharCode; }); + + // Attempt to improve the glyph mapping for (some) composite fonts that + // appear to lack meaningful ToUnicode data. + if (this.composite && this.toUnicode instanceof IdentityToUnicodeMap) { + if (/Verdana/i.test(name)) { // Fixes issue11242_reduced.pdf + const GlyphMapForStandardFonts = getGlyphMapForStandardFonts(); + for (charCode in GlyphMapForStandardFonts) { + map[+charCode] = GlyphMapForStandardFonts[charCode]; + } + } + } + this.toFontChar = map; } this.loadedName = fontName.split('-')[0]; this.fontType = getFontType(type, subtype); diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 27729226d..28f44733c 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -84,6 +84,7 @@ !issue11016_reduced.pdf !issue11045.pdf !issue11150_reduced.pdf +!issue11242_reduced.pdf !bad-PageLabels.pdf !decodeACSuccessive.pdf !filled-background.pdf diff --git a/test/pdfs/issue11242_reduced.pdf b/test/pdfs/issue11242_reduced.pdf new file mode 100644 index 000000000..469d178e1 Binary files /dev/null and b/test/pdfs/issue11242_reduced.pdf differ diff --git a/test/test_manifest.json b/test/test_manifest.json index e3a2f3642..98cd2420e 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -2208,6 +2208,13 @@ "rounds": 1, "type": "eq" }, + { "id": "issue11242", + "file": "pdfs/issue11242_reduced.pdf", + "md5": "ba50b6ee537f3e815ccfe0c99e598e05", + "link": false, + "rounds": 1, + "type": "eq" + }, { "id": "issue3323", "file": "pdfs/issue3323.pdf", "md5": "1a14ff574013caeafa9d598269988764",