diff --git a/src/core/fonts.js b/src/core/fonts.js index 5825a1470..993d3340b 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -484,8 +484,7 @@ function adjustMapping(charCodeToGlyphId, hasGlyph, newGlyphZeroId, toUnicode) { const isInPrivateArea = code => (PRIVATE_USE_AREAS[0][0] <= code && code <= PRIVATE_USE_AREAS[0][1]) || (PRIVATE_USE_AREAS[1][0] <= code && code <= PRIVATE_USE_AREAS[1][1]); - for (let originalCharCode in charCodeToGlyphId) { - originalCharCode |= 0; + for (const originalCharCode in charCodeToGlyphId) { let glyphId = charCodeToGlyphId[originalCharCode]; // For missing glyphs don't create the mappings so the glyph isn't // drawn. @@ -2834,7 +2833,7 @@ class Font { data: createPostTable(properties), }; - const charCodeToGlyphId = []; + const charCodeToGlyphId = Object.create(null); // Helper function to try to skip mapping of empty glyphs. function hasGlyph(glyphId) { diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index e458cc908..733a26e08 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -242,6 +242,7 @@ !ContentStreamNoCycleType3insideType3.pdf !ContentStreamCycleType3insideType3.pdf !issue2074.pdf +!issue18117.pdf !scan-bad.pdf !issue13561_reduced.pdf !bug847420.pdf diff --git a/test/pdfs/issue18117.pdf b/test/pdfs/issue18117.pdf new file mode 100644 index 000000000..2dd6038b9 Binary files /dev/null and b/test/pdfs/issue18117.pdf differ diff --git a/test/test_manifest.json b/test/test_manifest.json index 3b959e751..74bc215d9 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -5406,6 +5406,20 @@ "lastPage": 2, "type": "eq" }, + { + "id": "issue18117", + "file": "pdfs/issue18117.pdf", + "md5": "0be6391f9910d807a0ded5e6913ff7e3", + "rounds": 1, + "type": "eq" + }, + { + "id": "issue18117-text", + "file": "pdfs/issue18117.pdf", + "md5": "0be6391f9910d807a0ded5e6913ff7e3", + "rounds": 1, + "type": "text" + }, { "id": "issue4890", "file": "pdfs/issue4890.pdf",