diff --git a/src/core/fonts.js b/src/core/fonts.js index 9db048959..c03fbb62f 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -2901,14 +2901,21 @@ var Font = (function FontClosure() { } // Last, try to map any missing charcodes using the post table. - if (properties.glyphNames && baseEncoding.length) { + if ( + properties.glyphNames && + (baseEncoding.length || this.differences.length) + ) { for (let i = 0; i < 256; ++i) { - if (charCodeToGlyphId[i] === undefined && baseEncoding[i]) { - glyphName = baseEncoding[i]; - const glyphId = properties.glyphNames.indexOf(glyphName); - if (glyphId > 0 && hasGlyph(glyphId)) { - charCodeToGlyphId[i] = glyphId; - } + if (charCodeToGlyphId[i] !== undefined) { + continue; + } + glyphName = this.differences[i] || baseEncoding[i]; + if (!glyphName) { + continue; + } + const glyphId = properties.glyphNames.indexOf(glyphName); + if (glyphId > 0 && hasGlyph(glyphId)) { + charCodeToGlyphId[i] = glyphId; } } } diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 12f5eb3ff..15f105b38 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -158,6 +158,7 @@ !issue6019.pdf !issue6621.pdf !issue6286.pdf +!issue13107_reduced.pdf !issue1055r.pdf !issue11713.pdf !issue1293r.pdf diff --git a/test/pdfs/issue13107_reduced.pdf b/test/pdfs/issue13107_reduced.pdf new file mode 100644 index 000000000..60e59492f Binary files /dev/null and b/test/pdfs/issue13107_reduced.pdf differ diff --git a/test/test_manifest.json b/test/test_manifest.json index 0800d4c37..319959420 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -595,6 +595,12 @@ "link": false, "type": "eq" }, + { "id": "issue13107", + "file": "pdfs/issue13107_reduced.pdf", + "md5": "13c8d12223dec2752d3c90d250db32b7", + "rounds": 1, + "type": "eq" + }, { "id": "bug1186827", "file": "pdfs/bug1186827.pdf", "md5": "6c5526ae1a9d66cb517153001afc196e",