diff --git a/src/core/fonts.js b/src/core/fonts.js index 93c88263b..996dbf98d 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -4130,13 +4130,17 @@ var Font = (function FontClosure() { var charCodeToGlyphId = [], charCode; var toUnicode = properties.toUnicode, widths = properties.widths; - var isIdentityUnicode = toUnicode instanceof IdentityToUnicodeMap; + var skipToUnicode = (toUnicode instanceof IdentityToUnicodeMap || + toUnicode.length === 0x10000); + // Helper function to try to skip mapping of empty glyphs. + // Note: In some cases, just relying on the glyph data doesn't work, + // hence we also use a few heuristics to fix various PDF files. function hasGlyph(glyphId, charCode, widthCode) { if (!missingGlyphs[glyphId]) { return true; } - if (!isIdentityUnicode && charCode >= 0 && toUnicode.has(charCode)) { + if (!skipToUnicode && charCode >= 0 && toUnicode.has(charCode)) { return true; } if (widths && widthCode >= 0 && isNum(widths[widthCode])) { diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 8af0d7bbf..70e09390b 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -26,6 +26,7 @@ !issue4909.pdf !issue5202.pdf !issue5280.pdf +!issue5677.pdf !issue5954.pdf !alphatrans.pdf !devicen.pdf diff --git a/test/pdfs/issue5677.pdf b/test/pdfs/issue5677.pdf new file mode 100644 index 000000000..064c954a2 Binary files /dev/null and b/test/pdfs/issue5677.pdf differ diff --git a/test/test_manifest.json b/test/test_manifest.json index 543d2e767..f6137dc61 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -565,6 +565,13 @@ "link": false, "type": "load" }, + { "id": "issue5677", + "file": "pdfs/issue5677.pdf", + "md5": "c9101578fcb806269145132724d24ac1", + "rounds": 1, + "link": false, + "type": "eq" + }, { "id": "issue5954", "file": "pdfs/issue5954.pdf", "md5": "4f60ec0d9bbeec845b681242b8982361",