Description
When I set different font sizes, the small size text is partially obscured by the large size text
What MCU/Processor/Board and compiler are you using?
openwrt
What LVGL version are you using?
7.7
What do you want to achieve?
Different lines need to dynamically display different font sizes according to the length of the text
What have you tried so far?
A single line of font Settings will work, and multiple lines of different fonts will affect each other
Code to reproduce
Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.
The code block(s) should be formatted like:
lv_obj_t* createFxsLabel(lv_obj_t *scr,const char *label_text, int text_len,int h)
{
static lv_style_t font_style;
lv_style_init(&font_style);
const lv_font_t *font_size = &lv_font_montserrat_12; ;
if (text_len > 35) {
font_size = &lv_font_montserrat_8;
} else if (text_len > 24) {
font_size = &lv_font_montserrat_10;
} else {
font_size = &lv_font_montserrat_12;
}
lv_style_set_text_color(&font_style, LV_STATE_DEFAULT, LV_COLOR_BLACK);
lv_style_set_text_font(&font_style, LV_STATE_DEFAULT, font_size);
lv_obj_t *label = lv_label_create(scr, NULL);
if (label)
{
lv_obj_add_style(label,LV_LABEL_PART_MAIN, &font_style);
lv_label_set_text(label, label_text);
lv_obj_align(label, NULL, LV_ALIGN_IN_LEFT_MID, 60, 3+ 15 * h);
return label;
}
return NULL;
}
Screenshot and/or video
If possible, add screenshots and/or videos about the current state.