UTF-8 format for display º and %

It works to % thanks! and how can I display º?

I use “%0.2f°c”

Make sure that your C file is being saved in UTF-8 format. Sometimes the OS uses a different format, then the compiler outputs some other type of Unicode encoding and LVGL has no idea what to display.

Remember º is not always the same as ° there are about 2 or 3 symbols for degree…

no works for me, this only display c. Thanks!

And how can I make sure of that? Thanks!

Thats odd. The symbol is in the monterrat_26.c file. Line 1596. Can you try copying the symbol from there in case HTML is replacing it with something else?

Gabor was very kind to me, he added it in a while ago :slight_smile:

1 Like

if i understand correctly this symbol works for v7 !?

Yes, montserrat is the default in 7. Roboto in 6.

1 Like

ouuu, thanks, i`am loking later

Here is an example of it working:


It works the simbol of the monterrat_26.c file. Line 1596. it’s different than my keyboard symbol º. Thanks a lot!

Indeed. All degree symbols are not the same… :frowning:

thanks to you for your support

1 Like

good luck))

How do you select that background color? I divide my display in 3 parts, top, middle and bottom, my theme its LV_THEME_MATERIAL_FLAG_DARK but if I don’t select the color of the middle it is white, how can I setup your middle background color? Thanks a lot

bg_middle = lv_obj_create(scr, NULL);
    lv_obj_clean_style_list(bg_middle, LV_OBJ_PART_MAIN);
    lv_obj_set_style_local_bg_opa(bg_middle, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT,LV_OPA_COVER);
    lv_obj_set_style_local_bg_color(bg_middle, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
    lv_obj_set_pos(bg_middle, 0, 50);
    lv_obj_set_size(bg_middle, LV_HOR_RES, 240);

you can also use below for degree symbol.

printf("%.2f %cC", hum, 0xB0 );
1 Like

the font.c file should contain this degree symbol.
to add those symbols, you must include symbols.ttf file along with ascii ttf file while converting to font.c file.
this should definitely work.

For future people searching for the answer, I found a reliable solution to this that is working in LVGL v8.3:

  1. Create a custom font with this range of characters: 0x20-0x7F,0xB0 (the 0xB0 is the degree symbol).

  2. While using that font, format your string for rendering like this:

sprintf(buffer, "%d °C", degrees);

This embeds 0xC2 then 0xB0 which is the UTF-8 encoding for the degree symbol.

Then the rendering engine using that font will output a beautiful “99 °C”.

I hope that helps.

Kind regards,