It take a lots time when add freetype font into label

Hi @kisvegabor , @embeddedt and ALL

Description

I am using freetype library via lv_freetype.
At the time of add font into label object, it takes a lots more time than using binary font.
Is there any way to reduce this processing time?

Create font:

static lv_ft_info_t s_font_12;
s_font_12.name = "f_12";
s_font_12.weight = 12;
s_font_12.style = FT_FONT_STYLE_NORMAL;
lv_ft_font_init(&s_font_12)

Create label object:

static lv_obj_t *label;
static lv_style_t s_style_label;

lv_style_set_text_font(&s_style_label, LV_STATE_DEFAULT, s_font_12.font);
lv_obj_add_style(label, LV_LABEL_PART_MAIN, &s_style_label);

Exactly which function takes long time?

Hi @kisvegabor

It is lv_label_set_text().
Sorry, it is not included in above of code.
This function will take longer as the font size increases.

It’s strange.

Have you setting some caching?

Hi @kisvegabor

Use cache is a solution for me.

My largest font is less than 256, so I use sbit cache.

If I use 10 fonts size in my app,
how many should I set LV_FREETYPE_CACHE_FT_FACES and LV_FREETYPE_CACHE_FT_SIZES ?

I’m not an expert of FreeType (nor the details of how it’s integrated to LVGL) but if you are using the same font with 10 sizes you can set

  • LV_FREETYPE_CACHE_FT_FACES to 1
  • LV_FREETYPE_CACHE_FT_SIZES to 10

Thanks for your support.
Best regards!