How do you show a degree symbol?


I was wondering how to get a degree symbol to appear in LVGL.

Ive tried:
normal degree:
lv_table_set_cell_value(sensorTable, 1, 1, “20.25ºC”);

bodmer degree symbol replacement:
lv_table_set_cell_value(sensorTable, 1, 1, “20.25`C”);

I also tried:
lv_table_set_cell_value(sensorTable, 1, 1, “20.25°C”);

based on the degree symbol from:

but i get nothing.

Any ideas?


As far as I know the degree symbol is outside the basic ASCII range (0x20-0x7F). You need to add it to the converted font.

Ah, in which case can you tell me what the default font, size and BPP is for the night theme? I’ll need to create a font specifically for writing out my temps. Ive tried a number of different roboto ones but they dont look as good as the default one…

Ive tried to figure it out by looking at the source but must admit i’m getting out of my depth on that one…


The original Roboto is here: lvgl/scripts/built_in_font at master · lvgl/lvgl · GitHub

I’m pretty sure each of the 4 builtin Roboto fonts were converted with 4BPP, and you can figure out their size from their name.

Themes do not choose the default font; you do (in lv_conf.h).

Thank you for the pointer,

The answer is 4BPP, Size 16 but the crucial part is “Roboto Regular”. I tried most of the others and didn’t notice the “regular” option…

Thanks for the pointer and help

For future people searching for the answer, I found a reliable solution to this:

  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 “°C”.

I hope that helps.

Kind regards,

1 Like

FYI degree symbol has been included in default fonts for a while now:

1 Like

Understood. My details about what to include when creating a custom font is because all of the fonts I am using in firmware are custom, due to limitations in program space. I am making custom fonts to eliminate the character ranges I don’t need. Of course if one is using the built-in fonts, this is not needed. Thank you for pointing out my omission of this detail.

Postscript: Even more reliable (where you don’t have to worry about the file encoding) is this:

sprintf(buffer, "%d \xC2\xB0"  "C", degrees);

(The “C” at the end has to be separate, otherwise the compiler will try to interpret “…\B0C” as a 3-digit hex value.) The compiler (for C programmers not already familiar with this) joins the 2 as a single NUL-terminated string.