Repository navigation
Invert the font cmap once when subsetting - #183
Merged
Merged
Conversation
The subsetter found each glyph's codepoint by scanning 0..=0xFFFF per glyph. Hangul starts at U+AC00 and a glyph with no codepoint scanned the whole plane, so a Korean document with 1,000 distinct syllables spent about 4.7 s writing its font. The glyph-to-codepoint map is now built in one pass over the cmap, keeping each glyph's lowest BMP codepoint as the scan did: 85 ms, byte-identical output. The test checks the one-pass map against the full-plane scan for every glyph in six fonts (Noto Sans, Noto Emoji, Noto Naskh Arabic, Noto Sans Devanagari, Noto Sans Hebrew, Liberation Sans). Addresses #182. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the quick turnaround and the thorough verification! I'll test it on our invoices once it's released. |
This was referenced Oct 6, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses #182. Thanks @captyoungkyu for the precise diagnosis and patch; this is the same approach.
Font subsetting found each glyph's codepoint by scanning
0..=0xFFFFper glyph. Hangul starts at U+AC00, and a glyph with no codepoint (a ligature or shaped form) scanned the whole plane, so serialization time grew with the number of distinct Korean syllables. The glyph-to-codepoint map is now built in one pass over the font's Unicode cmap, keeping each glyph's lowest BMP codepoint as the scan did, so subset fonts are unchanged.Measured with Noto Sans KR, one page of Hangul (native CLI, before / after):
.notdefis excluded: a format 4 table's final segment maps U+FFFF to it, and the subsetter never gives it a cmap entry.