From 9ca13c9a237d5d96a796f3c2b81be5cf1b18026b Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 23 Jun 2026 13:51:37 +0200 Subject: [PATCH] Sort the mappings *last* in the `readCmapTable` function (PR 19321 follow-up) This improves performance of `issue19319.pdf` even more, and locally the rendering time of the second page goes from ~300 ms to ~250 ms, since we avoid sorting a bunch of duplicate entries. --- src/core/fonts.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/core/fonts.js b/src/core/fonts.js index dabdb4e84..0538c5e5c 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -1860,7 +1860,6 @@ class Font { } // removing duplicate entries - mappings.sort((a, b) => a.charCode - b.charCode); const finalMappings = [], seenCharCodes = new Set(); for (const map of mappings) { @@ -1876,7 +1875,7 @@ class Font { return { platformId: potentialTable.platformId, encodingId: potentialTable.encodingId, - mappings: finalMappings, + mappings: finalMappings.sort((a, b) => a.charCode - b.charCode), hasShortCmap, }; }