U8g2 Font List
Search and filter the U8g2 font constants by pixel height, see what every part of a font name means, and work out how many lines of your text fit on your OLED.
This is a layout simulation, not a pixel exact glyph render. Widths are exact for monospace fonts and estimated for proportional ones.
How to Read a U8g2 Font Name
Every font constant in the U8g2 library follows one scheme:
u8g2_font_<family>_<mode><charset>
u8g2_font_6x10_tr
| ||
| |+-- r: restricted ASCII 32-127
| +--- t: transparent drawing
+-------- 6x10: family name and cell sizeThe family part is either the cell size itself (6x10, 10x20), a typeface plus point size (ncenB14 = New Century Schoolbook Bold 14 px), or the font's own name (profont17, logisoso24).
Mode letters
| Letter | Meaning | When to use |
|---|---|---|
t | Transparent | The default choice. Only set pixels are drawn, the background is untouched. |
m | 8-pixel aligned | Writes the background too. Use it to overwrite an old value without clearing first. |
h | Common height | All glyphs share one height, for when line alignment matters. |
Charset letters
| Letter | Coverage | Approx glyphs |
|---|---|---|
r | Restricted, ASCII 32-127 | 96 |
f | Full, ASCII 32-255 | 224 |
n | Digits and a few marks (42-57) | 16 |
_t_cyrillic | Cyrillic | varies |
_t_greek | Greek | varies |
_t_symbols | Symbols and icons | varies |
The rule is simple: pick the smallest set you actually need. If the screen only shows a temperature, using tn instead of tf frees several kilobytes of flash.
What fits on a 128x64 display
| Font | Cell | Lines | Chars per line |
|---|---|---|---|
u8g2_font_4x6_tr | 4x6 | 10 | 32 |
u8g2_font_5x8_tr | 5x8 | 8 | 25 |
u8g2_font_6x10_tr | 6x10 | 6 | 21 |
u8g2_font_6x13_tr | 6x13 | 4 | 21 |
u8g2_font_7x14_tr | 7x14 | 4 | 18 |
u8g2_font_9x18_tr | 9x18 | 3 | 14 |
u8g2_font_10x20_tr | 10x20 | 3 | 12 |
Using a font
#include <U8g2lib.h>
U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE);
void setup() {
u8g2.begin();
}
void loop() {
u8g2.clearBuffer();
u8g2.setFont(u8g2_font_6x10_tr);
u8g2.drawStr(0, 10, "Temp: 23.4 C");
u8g2.setFont(u8g2_font_logisoso24_tn);
u8g2.drawStr(0, 45, "23.4");
u8g2.sendBuffer();
delay(1000);
}The y argument of drawStr is the baseline, not the top edge. If you pass a y smaller than the font height on the first line, the text runs off the top of the display.
Frequently Asked Questions
Is the preview pixel accurate?
No. The simulator does not draw the real glyph bitmaps. It works out from the display size, font height and character advance how many lines your text needs. Widths are exact for monospace fonts and estimated for proportional ones, and are labelled as such.
Nothing shows up on my display, why?
Two usual causes: forgetting that the y argument of drawStr is the baseline and passing 0 (the text sits above the screen), and skipping sendBuffer(). In full buffer (F) mode drawing only touches RAM; nothing reaches the panel until you call sendBuffer().
Accented characters are missing
The r charset only carries ASCII 32-127. Switch to an f font such as u8g2_font_6x13_tf, which covers Latin-1. Your sketch also has to send the right encoding; raw UTF-8 will draw each byte as a separate glyph.
Can I add my own font?
Yes. The bdfconv tool in the U8g2 repository converts a BDF font into a C array. A common alternative, if you only need a logo or an icon, is to skip fonts entirely and generate a bitmap with image2cpp, which is usually smaller.
Is any of my data sent anywhere?
No. Searching, filtering and the calculations all happen in your browser.