Getting Started

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)
ParameterDescription
displayTarget display — anything with SetPixel + Size
fontA Fonter value — pointer to one of the font variables
x, yTop-left origin of the text baseline (pixels)
strThe string to render (ASCII; full Unicode depends on font)
cForeground color as color.RGBA

Built-in fonts

The root package ships four bitmap fonts that range from tiny to small:

VariableSizeBest for
tinyfont.Tiny3x3a2pt7b3×3 pxStatus indicators, tiny labels
tinyfont.Picopixel~5 pxDense data on small OLEDs
tinyfont.TomThumb~6 pxCompact, very readable at small sizes
tinyfont.Org01~6 pxClean monospace look

Sub-packages (freemono, freesans, freeserif, notosans, proggy, gophers) add larger proportional and monospace faces at the cost of binary size.

docs