perf: subset built-in TTF fonts to ligature and kerning data - #54
Merged
Merged
Conversation
FreeInkFont only reads GSUB liga/rlig and GPOS kern, so the other layout features (small caps, figure styles, mark positioning, ...) in the embedded Bitter and Lexend Deca TTFs were dead flash. scripts/subset_scalable_fonts.py strips them in place, keeping every cmap codepoint and the name table (copyright and license strings). Raw TTFs 945,028 -> 659,500 B; x4-pro-light-sleep firmware 5,842,849 -> 5,557,872 B (-284,977 B). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013k1W4UZTzyPQnTVXwZUbkS
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.
Before: the embedded Bitter and Lexend Deca TTFs carried every OpenType layout feature (22 GSUB features in Bitter, GPOS mark/mkmk), none of which the firmware reads. x4-pro-light-sleep firmware was 5,842,849 B (89.2% of app0).
After: the fonts keep only GSUB liga/rlig and GPOS kern, which are the only lookups FreeInkFont performs (
lib/ScalableFont/ScalableGsub.h:73,freeink-sdk/libs/font/FreeInkFont/src/Gpos.cpp:226). The firmware is 5,557,872 B (84.8%), a saving of 284,977 B. Text renders the same.How: the new
scripts/subset_scalable_fonts.pysubsets each font inlib/EpdFont/scalableFonts/manifest.txtin place with fontTools. It keeps every cmap codepoint, keeps GDEF and the full name table (so the copyright and OFL strings stay), and drops DSIG and STAT. The fonts had no hinting tables to lose. Re-running it is a no-op. Raw TTFs go from 945,028 to 659,500 B.OutlineFingerprintchanges, so glyph caches keyed on it rebuild once.Hardware check (X4 Pro, light-sleep build): open an EPUB in Bitter and in Lexend Deca, in regular, bold and italic, and confirm the fi/fl ligatures and kerning (for example "AV", "To") look unchanged.
🤖 Generated with Claude Code
https://claude.ai/code/session_013k1W4UZTzyPQnTVXwZUbkS
Generated by Claude Code