https://github.com/huming2207/lvgl-ttf-esp32
LVGL + stb-truetype rendering TrueType on ESP32
https://github.com/huming2207/lvgl-ttf-esp32
esp-idf esp32 littlevgl lvgl truetype
Last synced: 2 months ago
JSON representation
LVGL + stb-truetype rendering TrueType on ESP32
- Host: GitHub
- URL: https://github.com/huming2207/lvgl-ttf-esp32
- Owner: huming2207
- Created: 2021-10-02T07:42:05.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2021-10-26T11:48:31.000Z (almost 4 years ago)
- Last Synced: 2025-03-27T16:21:32.423Z (7 months ago)
- Topics: esp-idf, esp32, littlevgl, lvgl, truetype
- Language: C
- Homepage:
- Size: 3.18 MB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# LittlevGL + stb_truetype PoC
This is a simple PoC for getting LVGL work with stb_truetype to render TrueType fonts on ESP32.
## Tips for Asian fonts
Asian fonts are usually huge, up to a few tens of MB. You may need to trim the font file before dumping it to ESP32.
To do so, have a look at [fontTools](https://fonttools.readthedocs.io/en/latest/). Install it by `pip install fonttools`
Then, for example, go to `main/resource` directory, and run:
```
pyftsubset wenquanyi.ttf --text-file=font_subset.txt --output-file=wqy.ttf
```...where in this case:
- `wenquanyi.ttf` is a famous Chinese font, [Wen Quan Yi](http://wenq.org/wqy2/index.cgi?action=browse&id=Home&lang=en), in TrueType format
- `font_subset.txt` is the font subset I need for this demo project
- `wqy.ttf` is the trimmed TrueType fontHere's what it will be like:

## To-do
1. Rasterize a lot of fonts may be a bit stressful for CPU and RAM. Therefore we probably need a KV database thing to handle font caching. One possible approach is to use ESP-IDF's NVS and prepare a separate NVS partition for fonts. Then store all rendered font bitmap cache to that partition.
2. Some heap allocations in stb_truetype can probably be avoided to prevent heap fragmentation.## License
MIT or Apache-2.0