-
-
Notifications
You must be signed in to change notification settings - Fork 960
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
backport lvgl fallback font to enable support for more language (via external flash font loading) #1473
Comments
Thanks @Boteium, this feature from LVGL 8.1 looks really interesting! We have not (yet) switched to lvgl8, mostly by lack of time to review the PR and fix remaining issues... I think this would be really interesting to test this feature backported in LVGL7 and see how well it performs! Just keep in mind that loading a font from external flash is quite slow, especially with bigger fonts. Also, the whole font will be stored in RAM, which means that we won't be able to have a huuuuge font that contains all characters from all languages, emojis,... because we are limited by RAM capacity. |
Oh, I didn't know that. Skimming through lvgl's source, It seems that lv_fs_open() does load the entire file into RAM just like you said. So, huge font (larger than ~20kb) can only be store in the precious system storage for now. |
I think this feature can still be very useful. For example, a huge fallback font is still possible if someone write a font engine that loads the bitmap on the fly from external flash in the future. Or, custom font stored in system storage can still save some space. |
We're preparing to use our own fork of LVGL. If you're interested in working on these ideas, feel free to open a PR in https://github.com/InfiniTimeOrg/lvgl |
Please check: lvgl/lvgl#4462 |
Verification
Pitch us your idea!
Let's backport font fallback to enable more languages and emoji
Description
Due to the small size of os storage, we can only fit a very small number of glyphs in the default font.
To support other non-English language, numerous forks have been created to support different language by adding glyphs to jetbrains_mono_bold_20 such as this one
Loading custom font from external storage is another idea that have been proposed several times. (e.g. #212 ) There are also watchfaces in current release that already use external flash to store fonts.
However, if a LV_LABEL is set to use a certain font. (as stated here)
lv_obj_set_style_local_text_font(label, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font);
It can only use the font specified here and cannot fallback to system font (e.g. jetbrains_mono_bold_20) if a glyph is not in this font. This means the custom font will have to duplicate everything in jetbrains_mono_bold_20 including ascii alnum, which is not very efficient.
Starting from LVGL 8.1, a fallback font can be selected. This way, only the extended glyphs (non-english alphabet, emoji ...) needs to be put in the custom font. Unfortunately, InfiniTime is currently using LVGL 7.
I think backporting this function should be considered since previous attempt to upgrade to LVGL 8 is stalled.
If I didn't miss anything, the following patch should be enough.
The text was updated successfully, but these errors were encountered: