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?
/*Memory used by FreeType to cache characters [bytes] (-1: no caching)*/
#define LV_FREETYPE_CACHE_SIZE (16 * 1024)
#if LV_FREETYPE_CACHE_SIZE >= 0
/* 1: bitmap cache use the sbit cache, 0:bitmap cache use the image cache. */
/* sbit cache:it is much more memory efficient for small bitmaps(font size < 256) */
/* if font size >= 256, must be configured as image cache */
#define LV_FREETYPE_SBIT_CACHE 0
/* Maximum number of opened FT_Face/FT_Size objects managed by this cache instance. */
/* (0:use system defaults) */
#define LV_FREETYPE_CACHE_FT_FACES 0
#define LV_FREETYPE_CACHE_FT_SIZES 0
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!