diff --git a/src/core/fonts.js b/src/core/fonts.js index 8dcda2a20..67f8c2b27 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -1760,17 +1760,22 @@ class Font { mappings.sort(function (a, b) { return a.charCode - b.charCode; }); - for (let i = 1; i < mappings.length; i++) { - if (mappings[i - 1].charCode === mappings[i].charCode) { - mappings.splice(i, 1); - i--; + const finalMappings = [], + seenCharCodes = new Set(); + for (const map of mappings) { + const { charCode } = map; + + if (seenCharCodes.has(charCode)) { + continue; } + seenCharCodes.add(charCode); + finalMappings.push(map); } return { platformId: potentialTable.platformId, encodingId: potentialTable.encodingId, - mappings, + mappings: finalMappings, hasShortCmap, }; } diff --git a/test/pdfs/issue19319.pdf.link b/test/pdfs/issue19319.pdf.link new file mode 100644 index 000000000..98295cd81 --- /dev/null +++ b/test/pdfs/issue19319.pdf.link @@ -0,0 +1 @@ +https://github.com/user-attachments/files/18396493/2023-ESG-report-eng.pdf diff --git a/test/test_manifest.json b/test/test_manifest.json index e50d5cadf..89ab0677c 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -11254,5 +11254,15 @@ "rounds": 1, "link": true, "type": "other" + }, + { + "id": "issue19319", + "file": "pdfs/issue19319.pdf", + "md5": "8612d3f0cf2dd067ea4aec9c8bf98763", + "rounds": 1, + "link": true, + "firstPage": 2, + "lastPage": 2, + "type": "eq" } ]