feat(font) add fallback support and mem. font load option to FreeType (#2796)

* adding font type check

* using theme specified font
supports freetype drawing

* adding font type check

* using theme specified font
supports freetype drawing

* freetype fallback font support

* improved fallback font

* updated fallback font modifier

* docs(events) LV_EVENT_APPLY was removed (#2791)

* reverted to default font logic

* removed unused function

* improved font fallback

* font fallback for default lv_draw_letter as well

* added back masked drawing support

* fallback support for freetype uncached

* updated description

* fixed constructor initialization for ISO C

* reverted unneeded changes

* using loop instead of recursion to resolve glyph info

* simplified glyph dec resolving

* removed unused enum value

* improved lv_font_fmt_ft_dsc_t field naming

* supports pointer as freetype font source

* Updated docs for font fallback

Co-authored-by: Vincent Hamp <higaski@users.noreply.github.com>
Co-authored-by: Gabor Kiss-Vamosi <kisvegabor@gmail.com>
This commit is contained in:
Mariotaku
2021-11-22 18:43:58 +09:00
committed by GitHub
parent 57cde348fa
commit 3ea4d66411
10 changed files with 94 additions and 176 deletions

View File

@@ -251,3 +251,19 @@ const uint8_t * my_get_glyph_bitmap_cb(const lv_font_t * font, uint32_t unicode_
return bitmap; /*Or NULL if not found*/
}
```
## Use font fallback
You can specify `fallback` in `lv_font_t` to provide fallback to the font. When the font
fails to find glyph to a letter, it will try to let font from `fallback` to handle.
`fallback` can be chained, so it will try to solve until there is no `fallback` set.
```c
/* Roboto font doesn't have support for CJK glyphs */
lv_font_t *roboto = my_font_load_function();
/* Droid Sans Fallback has more glyphs but its typeface doesn't look good as Roboto */
lv_font_t *droid_sans_fallback = my_font_load_function();
/* So now we can display Roboto for supported characters while having wider characters set support */
roboto->fallback = droid_sans_fallback;
```