Change the font for some of the labels


I cannot find reliable information on how I can change the size of a certain label (without affecting others). I understand that this would mean referencing a different font to that object, but I cannot find the right API for this.

What MCU/Processor/Board and compiler are you using?


What LVGL version are you using?


What do you want to achieve?

Have labels with different (font) text sizes.

What have you tried so far?

Googled for answers, only found examples using outdated and no longer available API calls, also a bunch of broken links. Even the link to the PC simulator link in this forum form is broken. I checked the documentation, doesn’t say anything about how fonts can be changed for certain objects.

You can do this by changing the text_font property of the label’s style. The correct APIs to use would either be lv_style_set_text_font (for a style that can be applied to multiple objects) or lv_obj_set_style_local_text_font (to change the font of a specific label).

Thanks for the hint, here’s the wrapper function we have added to do this (since all these other parameters are quite hard to comprehend):

void SetLabelFont(lv_obj_t *obj, lv_font_t *font)
    lv_obj_set_style_local_text_font(obj, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font);