Color font support for LVGL #2255
Comments
|
I really like the idea. I'd also allow using color fonts like these. I think the largest barrier is finding a suitable rendered that can produce an LVGL-digestible simple format. AFAIK FreeType (the rendered we currently use) doesn't support it. This comment says FreeType supports only RGB images and vector color fonts. This gist shows how to load bitmap fonts. |
|
@kisvegabor It appears that FreeType 2.10 (which was released a month after that answer) does in fact support rendering the "Segoe UI Emoji" font, so I assume that it will work for any other emoji fonts as well. |
|
This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
|
Ups, sorry, I forgot to comment here. Is there someone who has the linking to make some tests with it? |
|
Good to know, thanks! |
|
Simple support experiments : add draw color font code in deps/lvgl/src/draw/lv_draw_label.c, like this : LV_ATTRIBUTE_FAST_MEM static void draw_letter_normal(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_dsc_t * g,
const lv_area_t * clip_area,
const uint8_t * map_p, lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode)
{
const uint8_t * bpp_opa_table_p;
uint32_t bitmask_init;
uint32_t bitmask;
uint32_t bpp = g->bpp;
uint32_t shades;
if(bpp == 3) bpp = 4;
//draw color font
if (bpp == 32) {
lv_area_t fill_area;
fill_area.x1 = pos_x;
fill_area.y1 = pos_y;
fill_area.x2 = pos_x + g->box_w - 1;
fill_area.y2 = pos_y + g->box_h - 1;
_lv_blend_map(clip_area, &fill_area, (lv_color_t*)map_p, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode);
return;
}in get_glyph_dsc_cb_nocache of lv_lib_freetype, add error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT | FT_LOAD_COLOR);
.....
dsc_out->bpp = face->glyph->bitmap.pixel_mode == FT_PIXEL_MODE_BGRA ? 32 : 8; /*Bit per pixel: 1/2/4/8*/
|
|
Wow, it was very simple in LVGL. One thing is that we should support 16 bit color depth too. #2569 will merge lv_lib_freetype into lvgl. After that a PR for it would be very very welcome |

For more deeper thinking from #2144 (comment).
I also wonder to know how to make the LVGL to support the color font. (I wonder to add support for the color glyphs for Unicode Emoji characters in LVGL and make it looks as good as the app with the modern UI technology.)
The introduction of the color font: https://docs.microsoft.com/en-us/windows/win32/directwrite/color-fonts
The text was updated successfully, but these errors were encountered: