-
Notifications
You must be signed in to change notification settings - Fork 31
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
Is it possible to load a new font from jsx ? #15
Comments
Currently this is not supported through the JavaScript binding. You should be able though to go into the LVGL dependency that is vendored in this repo and follow these steps here to get a binary that replaces the builtin font with your custom glyphs. |
PRs are welcome though. I feel this should be a fairly low lift, but we would need to build a separate |
bad link |
Sorry, here's the right link. Nothing special more than LVGL Font documentation... See the "Add a new font" section. I tried to take a stab at a way to load fonts from JS, but it seems like LVGL FS is not supported in this binding. @kisvegabor is there a way to load fonts from a buffer instead of using LVGL FS? |
There is no way for it at this moment. 🙁 |
Images are currently handled through a buffer, so I thought it would be nice to have similar handling for fonts, so that bindings that already have FS support could use their own APIs. In the meantime, I will look into how to integrate with the LVGL FS API as an alternative. The benefit is that it should work for every platform supported by LVGL (for example, I'm aiming to have an ESP32 build target). |
We can do 2 things:
I vote for 1). We could use some function pointers like What do you think? |
Option 1 sounds like the cleanest approach to me, as it allows to leverage virtually any loading method -- generating a header file with a a statically allocated buffer, loading from an HTTP source, loading from a native binding, etc -- especially if it doesn't require including and compiling the FS module/drivers |
Great, we are on the same page then 🙂 Are you interested in adding this feature to LVGL? No problem if not, I can open an issue an see if someone picks it up. |
Sounds like a fun little task to take on :) but right now kind of limited in bandwidth to ramp up in a whole new environment 😛 Feel free to open an issue! If someone picks up, great, otherwise I may pick it up in the future. There's a ton I still need to learn about the platform I'm targeting |
Done 🙂 lvgl/lvgl#4448 |
I got this working locally! Once lvgl/lvgl#4462 lands in LVGL master it should be possible to load fonts using an API similar to the one below: More sizes and fonts:
Open for feedback on the font loading and registering API:
The caveat of this font loading work is that it will depend on LVGL master branch. This binding master currently points to LVGL v8. I genuinely do not have experience with the stability of LVGL master branch, so in the meantime I can push this into a separate LVGL master-compatible branch. |
LVGL |
@kisvegabor is it common for features to be back ported to v8? If so, would it make sense to back port this API? |
Normally we rarely backport features to v8 as we are not planning to create new v8 minor releases. However if it's important for the JS binding we can make an exception. |
For example, the default font has no Cyrillic support.
api for C:
https://docs.lvgl.io/master/overview/font.html
The text was updated successfully, but these errors were encountered: