Understanding the available fonts

I have the Arduino Sensor Kit and I'm fiddling around with the display. I've come so far that I can choose fonts from the file named u8x8.h, which I found on my computer. The file has a huge list of fonts and the listing looks as follows:

...
extern const uint8_t u8x8_font_pxplusibmcgathin_n[] U8X8_FONT_SECTION("u8x8_font_pxplusibmcgathin_n");
extern const uint8_t u8x8_font_pxplusibmcgathin_u[] U8X8_FONT_SECTION("u8x8_font_pxplusibmcgathin_u");
extern const uint8_t u8x8_font_pxplusibmcga_f[] U8X8_FONT_SECTION("u8x8_font_pxplusibmcga_f");
extern const uint8_t u8x8_font_pxplusibmcga_r[] U8X8_FONT_SECTION("u8x8_font_pxplusibmcga_r");
extern const uint8_t u8x8_font_pxplusibmcga_n[] U8X8_FONT_SECTION("u8x8_font_pxplusibmcga_n");
extern const uint8_t u8x8_font_pxplusibmcga_u[] U8X8_FONT_SECTION("u8x8_font_pxplusibmcga_u");
extern const uint8_t u8x8_font_pxplustandynewtv_f[] U8X8_FONT_SECTION("u8x8_font_pxplustandynewtv_f");
extern const uint8_t u8x8_font_pxplustandynewtv_r[] U8X8_FONT_SECTION("u8x8_font_pxplustandynewtv_r");
extern const uint8_t u8x8_font_pxplustandynewtv_n[] U8X8_FONT_SECTION("u8x8_font_pxplustandynewtv_n");
extern const uint8_t u8x8_font_pxplustandynewtv_u[] U8X8_FONT_SECTION("u8x8_font_pxplustandynewtv_u");
extern const uint8_t u8x8_font_px437wyse700a_2x2_f[] U8X8_FONT_SECTION("u8x8_font_px437wyse700a_2x2_f");
extern const uint8_t u8x8_font_px437wyse700a_2x2_r[] U8X8_FONT_SECTION("u8x8_font_px437wyse700a_2x2_r");
extern const uint8_t u8x8_font_px437wyse700a_2x2_n[] U8X8_FONT_SECTION("u8x8_font_px437wyse700a_2x2_n");
extern const uint8_t u8x8_font_px437wyse700b_2x2_f[] U8X8_FONT_SECTION("u8x8_font_px437wyse700b_2x2_f");
...

From here I can use almost anyone in my code, like:

  Oled.setFont(u8x8_font_pxplustandynewtv_f); 
  Oled.setCursor(0, 0);    // Set the Coordinates 
  Oled.print("L\xE4mp\xF6   ");

I've learned that fonts ending with _f allow me to print scandinavian diacritics. My string "L\xE4mp\xF6" becomes "Lämpö". Nice! But what do the other endings imply? We have fonts ending in _r, _n and _u, too.

And where exactly could I find info about these fonts? I could try out these all fonts and figure out how to create a reference manual of them, but I guess such manual exists somewhere. I haven't found any.

have a look in the documentation

Home · olikraus/u8g2 Wiki · GitHub

U8g2 Font names

<prefix> '_' <name> '_' <purpose> <char set>
<purpose> Description
t Transparent font, Do not use a background color.
h All glyphs have common height.
m All glyphs have common height and width (monospace).
8 All glyphs fit into a 8x8 pixel box.
<char set> Description
f The font includes up to 256 glyphs.
r Only glyphs on the range of the ASCII codes 32 to 127 are included in the font.
u Only glyphs on the range of the ASCII codes 32 to 95 (uppercase chars) are included in the font.
n Only numbers and extra glyphs for writing date and time strings are included in the font.
... Other custom character list.
2 Likes

The original bdf (bitmap distribution format) files for the fonts are available at https://github.com/olikraus/u8g2/tree/master/tools/font/bdf if you want to look at the complete font set, or create a custom subset of a font for U8g2/U8x8 (useful when you need to aggressively conserve memory).

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.