Merge pull request #19321 from Snuffleupagus/issue-19319
Improve performance when reading very large TrueType "cmap" tables (issue 19319)
This commit is contained in:
commit
61995e9e37
@ -1760,17 +1760,22 @@ class Font {
|
|||||||
mappings.sort(function (a, b) {
|
mappings.sort(function (a, b) {
|
||||||
return a.charCode - b.charCode;
|
return a.charCode - b.charCode;
|
||||||
});
|
});
|
||||||
for (let i = 1; i < mappings.length; i++) {
|
const finalMappings = [],
|
||||||
if (mappings[i - 1].charCode === mappings[i].charCode) {
|
seenCharCodes = new Set();
|
||||||
mappings.splice(i, 1);
|
for (const map of mappings) {
|
||||||
i--;
|
const { charCode } = map;
|
||||||
|
|
||||||
|
if (seenCharCodes.has(charCode)) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
seenCharCodes.add(charCode);
|
||||||
|
finalMappings.push(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
platformId: potentialTable.platformId,
|
platformId: potentialTable.platformId,
|
||||||
encodingId: potentialTable.encodingId,
|
encodingId: potentialTable.encodingId,
|
||||||
mappings,
|
mappings: finalMappings,
|
||||||
hasShortCmap,
|
hasShortCmap,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
1
test/pdfs/issue19319.pdf.link
Normal file
1
test/pdfs/issue19319.pdf.link
Normal file
@ -0,0 +1 @@
|
|||||||
|
https://github.com/user-attachments/files/18396493/2023-ESG-report-eng.pdf
|
||||||
@ -11254,5 +11254,15 @@
|
|||||||
"rounds": 1,
|
"rounds": 1,
|
||||||
"link": true,
|
"link": true,
|
||||||
"type": "other"
|
"type": "other"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "issue19319",
|
||||||
|
"file": "pdfs/issue19319.pdf",
|
||||||
|
"md5": "8612d3f0cf2dd067ea4aec9c8bf98763",
|
||||||
|
"rounds": 1,
|
||||||
|
"link": true,
|
||||||
|
"firstPage": 2,
|
||||||
|
"lastPage": 2,
|
||||||
|
"type": "eq"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user