How to change font size

I want to change the font size for the text that I have. How can I change it?
There is some online tool to do that but I am not sure how this process works?
is there a complete example?

lv_conf.h (or lv_conf_template.h if you haven’t changed the name yet) contains built-in fonts that you can use by the name LV_FONT_MONTSERRAT_x with x being the size. You can set the font directly like this:

lv_label_set_text(label, "Test");
lv_obj_set_style_text_font(label, &lv_font_montserrat_20, 0);

You’'ll have to enable the font in lv_conf.h by setting
#define LV_FONT_MONTSERRAT_20 1

You will also find more font-specific defines inside the lv_conf.h

@krembed
Thanks for your reply.
Your solution works. And I could increase the font size. Quite appreciate.
However, I struggled yesterday almost whole day to do this.! I tried to find solution online, change style, use the font tool to change size, etc, etc.
Can you tell how to use different format fonts?

I’m glad it works. What exactly do you mean by format fonts? You mean bold and italic styles? I haven’t included a custom font myself yet, but as you’ve mentioned before there’s the online font converter. You upload your TTF or WOFF font, choose the size and select ranges (the example shows e.g. 0x20-0x7F which should be ASCII with 0x20 being Space and 0x7F being DEL). When you convert the font you will get a .c file e.g. my_font.c, to use it you declare it using LV_FONT_DECLARE e.g. LV_FONT_DECLARE(my_font);
and apply it with
lv_obj_set_style_text_font(label, &my_font, 0);

You can also modify your lv_conf.h to make the font global by using
#define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font)
By doing this you can use your custom font the same way you use any of the lv_font_montserrat fonts

1 Like

Ok. I will try that and let you know if it works for me.!