diff --git a/src/core/fonts.js b/src/core/fonts.js index 24ed0139c..9bab29cef 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -2955,10 +2955,7 @@ class Font { // Always prefer the BaseEncoding/Differences arrays, when they exist // (fixes issue13433.pdf). forcePostTable = true; - } else { - // When there is only a (1, 0) cmap table, the char code is a single - // byte and it is used directly as the char code. - + } else if (cmapPlatformId === 3 && cmapEncodingId === 0) { // When a (3, 0) cmap table is present, it is used instead but the // spec has special rules for char codes in the range of 0xF000 to // 0xF0FF and it says the (3, 0) table should map the values from @@ -2969,15 +2966,17 @@ class Font { // cmap. for (const mapping of cmapMappings) { let charCode = mapping.charCode; - if ( - cmapPlatformId === 3 && - charCode >= 0xf000 && - charCode <= 0xf0ff - ) { + if (charCode >= 0xf000 && charCode <= 0xf0ff) { charCode &= 0xff; } charCodeToGlyphId[charCode] = mapping.glyphId; } + } else { + // When there is only a (1, 0) cmap table, the char code is a single + // byte and it is used directly as the char code. + for (const mapping of cmapMappings) { + charCodeToGlyphId[mapping.charCode] = mapping.glyphId; + } } // Last, try to map any missing charcodes using the post table. diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 0fcd81388..87a32129f 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -636,3 +636,4 @@ !bug1868759.pdf !issue17730.pdf !bug1883609.pdf +!issue17808.pdf diff --git a/test/pdfs/issue17808.pdf b/test/pdfs/issue17808.pdf new file mode 100755 index 000000000..65d89961c Binary files /dev/null and b/test/pdfs/issue17808.pdf differ diff --git a/test/test_manifest.json b/test/test_manifest.json index 65168819f..8927ba30e 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -9794,5 +9794,12 @@ "rounds": 1, "link": true, "type": "other" + }, + { + "id": "issue17808", + "file": "pdfs/issue17808.pdf", + "md5": "dd66194bdaa0f62bc96c760384f2e098", + "rounds": 1, + "type": "eq" } ]