Skip to content

Commit 9416580

Browse files
font-manager: document which built-in faces are uncompressed, and why
The 12px (getFont default) and 16px Montserrat faces ship uncompressed: RLE compression decodes every glyph on every draw, measured on the badge at 0.062 -> 0.037ms per glyph at 12px and 0.056 -> 0.034ms at 16px, so a full text screen repaints ~20ms faster for +6.7KB of firmware. Also records how to benchmark a candidate size before changing it.
1 parent c19bfcc commit 9416580

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎docs/frameworks/font-manager.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,21 @@ Emoji PNGs are stored in `builtin/res/emojis/`:
7676
| `_imgfont_source_size_cache` | `src` | `(width, height)` tuple |
7777
| `_imgfont_empty_src_cache` | `target_height` | 1×h transparent `lv.image_dsc_t` |
7878

79+
### Built-in bitmap fonts and compression
80+
81+
The built-in Montserrat faces live in `lvgl_micropython/lib_lvgl_src_font/` and are copied into LVGL at build time. Most sizes are stored **RLE-compressed** (`LV_FONT_FMT_TXT_COMPRESSED`) to save flash, which means LVGL decompresses every glyph on every draw.
82+
83+
That per-glyph decode is measurable, so the two faces the UI uses most are shipped **uncompressed** on purpose:
84+
85+
| Face | Where it is used | Compressed | Uncompressed |
86+
|------|------------------|-----------|--------------|
87+
| 12 px | `getFont()` default, theme body text — the most used size | 0.062 ms/glyph | **0.037 ms/glyph** |
88+
| 16 px | Second most used size (titles, list headers) | 0.056 ms/glyph | **0.034 ms/glyph** |
89+
90+
Measured on an ESP32-S3 badge with identical text and size: a full text screen (18 lines × 44 characters = 792 glyphs) redraws in **54.1 ms instead of 74.4 ms**, about 20 ms per full-screen repaint. The cost is **+6.7 KB of firmware** for both faces. The remaining sizes (10, 14, 18, 20, 24, 28) stay compressed — they are used far less and the flash saving is worth more there.
91+
92+
If you add a new hot font size, benchmark it before deciding: load a compressed and an uncompressed build of the same face with `lv.binfont_create_from_buffer()` and time a full `scr.invalidate()` + `lv.refr_now()` loop with and without text. The regeneration recipe and the exact per-size `lv_font_conv` options are documented in `lvgl_micropython/lib_lvgl_src_font/README.md`; each generated `.c` file also carries its own `Opts:` line in the header comment.
93+
7994
## API Reference
8095

8196
### `getFont(size=None, ttf=None, family=None, emoji=False)`

0 commit comments

Comments
 (0)