diff --git a/CHANGELOG.md b/CHANGELOG.md index c0b6da91392..2c4c31cc4ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ - Reversing a brightness or warmth drag partway now moves the level past where it started instead of stopping there. - Idle power saving now puts the device into automatic light sleep between loop ticks instead of only lowering the CPU clock, cutting idle draw while leaving buttons, touch, and the frontlight working exactly as before. The screen, Wi-Fi transfers, and USB sessions stay awake while they are in use. - GitHub workflows and release documentation links now follow the `development` default branch. +- The built-in Bitter and Lexend Deca TTF fonts carry only the ligature and kerning data the reader uses, freeing about 290 KB of flash on ESP32-S3 builds. Text renders the same. - Idle power saving now engages after 250 ms instead of 3 seconds, and battery level is polled every 6 seconds instead of every 1.5, trading slightly less frequent battery updates for lower average power draw. - The Library opens instantly when nothing on the SD card has changed since its last scan, instead of rescanning the whole card on every visit. Moving the selection no longer re-reads each visible book from the card. - After a restart, Home starts indexing the Library in the background as soon as it appears, so the first Library visit usually opens without the "Reading your books" wait. Indexing pauses the moment you press a button or touch the screen and picks up where it left off. diff --git a/lib/EpdFont/scalableFonts/bitter_bold.ttf b/lib/EpdFont/scalableFonts/bitter_bold.ttf index 0a6a38ac440..09e3684a988 100644 Binary files a/lib/EpdFont/scalableFonts/bitter_bold.ttf and b/lib/EpdFont/scalableFonts/bitter_bold.ttf differ diff --git a/lib/EpdFont/scalableFonts/bitter_bolditalic.ttf b/lib/EpdFont/scalableFonts/bitter_bolditalic.ttf index 4141d2283b0..d7a919c02dd 100644 Binary files a/lib/EpdFont/scalableFonts/bitter_bolditalic.ttf and b/lib/EpdFont/scalableFonts/bitter_bolditalic.ttf differ diff --git a/lib/EpdFont/scalableFonts/bitter_italic.ttf b/lib/EpdFont/scalableFonts/bitter_italic.ttf index 8e66d89304a..5f3eaa7d2c7 100644 Binary files a/lib/EpdFont/scalableFonts/bitter_italic.ttf and b/lib/EpdFont/scalableFonts/bitter_italic.ttf differ diff --git a/lib/EpdFont/scalableFonts/bitter_regular.ttf b/lib/EpdFont/scalableFonts/bitter_regular.ttf index ae896cccf99..e7c2bb28b1c 100644 Binary files a/lib/EpdFont/scalableFonts/bitter_regular.ttf and b/lib/EpdFont/scalableFonts/bitter_regular.ttf differ diff --git a/lib/EpdFont/scalableFonts/lexenddeca_bold.ttf b/lib/EpdFont/scalableFonts/lexenddeca_bold.ttf index dff0ffc7df2..d5fa48f4a89 100644 Binary files a/lib/EpdFont/scalableFonts/lexenddeca_bold.ttf and b/lib/EpdFont/scalableFonts/lexenddeca_bold.ttf differ diff --git a/lib/EpdFont/scalableFonts/lexenddeca_bolditalic.ttf b/lib/EpdFont/scalableFonts/lexenddeca_bolditalic.ttf index 62d2427b164..e79a6cea464 100644 Binary files a/lib/EpdFont/scalableFonts/lexenddeca_bolditalic.ttf and b/lib/EpdFont/scalableFonts/lexenddeca_bolditalic.ttf differ diff --git a/lib/EpdFont/scalableFonts/lexenddeca_italic.ttf b/lib/EpdFont/scalableFonts/lexenddeca_italic.ttf index 0f3ff6bf774..a2f14669a2c 100644 Binary files a/lib/EpdFont/scalableFonts/lexenddeca_italic.ttf and b/lib/EpdFont/scalableFonts/lexenddeca_italic.ttf differ diff --git a/lib/EpdFont/scalableFonts/lexenddeca_regular.ttf b/lib/EpdFont/scalableFonts/lexenddeca_regular.ttf index 680906a4d9c..8bac0a5b0d2 100644 Binary files a/lib/EpdFont/scalableFonts/lexenddeca_regular.ttf and b/lib/EpdFont/scalableFonts/lexenddeca_regular.ttf differ diff --git a/scripts/subset_scalable_fonts.py b/scripts/subset_scalable_fonts.py new file mode 100644 index 00000000000..a75e9547e51 --- /dev/null +++ b/scripts/subset_scalable_fonts.py @@ -0,0 +1,39 @@ +"""Strip the embedded reader TTFs down to the tables FreeInkFont reads. + +The firmware only looks up GSUB liga/rlig (lib/ScalableFont/ScalableGsub.h) and +GPOS kern (freeink-sdk/libs/font/FreeInkFont/src/Gpos.cpp). Every other layout +feature (small caps, old-style figures, mark positioning, ...) is dead weight in +flash. Run after replacing a font in lib/EpdFont/scalableFonts; safe to re-run. + +Requires fonttools (pip install fonttools). +""" +from pathlib import Path + +from fontTools import subset +from fontTools.ttLib import TTFont + +FEATURES = ['liga', 'rlig', 'kern'] + + +def main(): + source = Path(__file__).resolve().parents[1] / 'lib/EpdFont/scalableFonts' + options = subset.Options() + options.layout_features = FEATURES + options.name_IDs = ['*'] # keep copyright and license strings + options.name_languages = ['*'] + options.hinting = False + options.drop_tables += ['DSIG', 'STAT'] + options.notdef_outline = True + for filename in (source / 'manifest.txt').read_text().splitlines(): + path = source / filename + before = path.stat().st_size + font = TTFont(path) + subsetter = subset.Subsetter(options) + subsetter.populate(unicodes=font.getBestCmap().keys()) + subsetter.subset(font) + font.save(path) + print(f'{filename:28} {before:>7} B -> {path.stat().st_size:>7} B') + + +if __name__ == '__main__': + main()