U8x8: Fonts
This is a fan favorite. It is a clean, modern sans-serif font designed specifically for small OLEDs. It features distinct letters and good contrast.
The standard fonts are great, but what if you need Japanese characters, custom icons, or a specific corporate logo? You can create custom u8x8 fonts.
The U8g2 library includes a tool called bdfconv (BDF Converter). BDF (Glyph Bitmap Distribution Format) is a standard text-based font format.
Workflow:
Alternatively, you can manually define a font in C:
static const uint8_t my_custom_font[] =
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Space
0x00, 0x00, 0x5F, 0x00, 0x00, 0x00, 0x00, 0x00, // !
// ... and so on for 256 characters
;
(Note: The order of bytes depends on your display's page layout.)
Cause: You are using a U8g2 font with a U8x8 constructor or vice versa.
Fix: Ensure you use u8x8.setFont(u8x8_font_...); (note the u8x8_ prefix) not u8g2.setFont(...). u8x8 fonts
Imagine graph paper. A standard U8x8 font carves that paper into 8x8 blocks. Inside each block, individual pixels are turned on or off to form a letter, number, or symbol.
Because each row of the character is stored as a single byte (8 bits = 1 byte), rendering is astonishingly fast. The microcontroller doesn't need to calculate variable widths or kerning; it simply copies 8 bytes from Flash memory to the display's buffer for every character.
Library Manager → search "U8g2" → install. This is a fan favorite
On a platform like an ATmega328P (Arduino Uno), you have only 2KB of SRAM. Rendering a full framebuffer for a 128x64 pixel display requires (128 * 64) / 8 = 1024 bytes — that's half your RAM gone in one shot.
U8x8 fonts circumvent this entirely. Because the font is fixed-width and the display operates in page mode (a concept dating back to the original KS0108 and SSD1306 drivers), the library writes characters directly to the display without a full frame buffer.
All U8x8 font names start with u8x8_font_. Here are the most useful ones: Alternatively, you can manually define a font in
| Font Name | Size | Style | Best for |
|------------------------------------|--------|----------------------|----------------------------------|
| u8x8_font_8x13_1x2_n | 8x13 | Normal | Readable, medium density |
| u8x8_font_8x13B_1x2_n | 8x13 | Bold | Headers, emphasis |
| u8x8_font_amstrad_cpc_extended_f | 8x8 | Retro / blocky | Retro UIs |
| u8x8_font_pxplusibmcgothin_8u | 8x8 | Thin, modern | Small, crisp text |
| u8x8_font_inb21_2x4_n | 8x21? | Large (2x4 scaling) | Big numbers / status |
| u8x8_font_5x7_f | 5x7 | Tiny | Dense info (needs 5x7 grid) |
| u8x8_font_artosserif8_r | 8x8 | Serif | Elegant text |
Naming convention:
u8x8_font_<name>_<width>_<height>_<flags>
Flags:f= full,n= narrow,r= restricted chars,u= upper-only.