Getting Started
tinygo.org/x/tinyfont is a lightweight font rendering library designed for microcontrollers. It works with any display that implements the drivers.Displayer interface — OLEDs, TFT screens, e-ink panels — and draws text one pixel at a time, making it ideal for resource-constrained environments where a full font engine would be too large.
Quick start
import (
"image/color"
"tinygo.org/x/tinyfont"
)
// disp is any drivers.Displayer (e.g. an SSD1306 OLED or ILI9341 TFT)
tinyfont.WriteLine(disp, &tinyfont.TomThumb, 2, 14, "Hello!", color.RGBA{R: 0xff, A: 0xff})
WriteLine signature:
func WriteLine(display drivers.Displayer, font Fonter, x, y int16, str string, c color.RGBA)
| Parameter | Description |
|---|---|
display | Target display — anything with SetPixel + Size |
font | A Fonter value — pointer to one of the font variables |
x, y | Top-left origin of the text baseline (pixels) |
str | The string to render (ASCII; full Unicode depends on font) |
c | Foreground color as color.RGBA |
Built-in fonts
The root package ships four bitmap fonts that range from tiny to small:
| Variable | Size | Best for |
|---|---|---|
tinyfont.Tiny3x3a2pt7b | 3×3 px | Status indicators, tiny labels |
tinyfont.Picopixel | ~5 px | Dense data on small OLEDs |
tinyfont.TomThumb | ~6 px | Compact, very readable at small sizes |
tinyfont.Org01 | ~6 px | Clean monospace look |
Sub-packages (freemono, freesans, freeserif, notosans, proggy, gophers) add larger proportional and monospace faces at the cost of binary size.