API Reference & Examples

API Reference & Examples

The drivers.Displayer interface

type Displayer interface {
    // SetPixel draws a single pixel at (x, y) with color c.
    SetPixel(x, y int16, c color.RGBA)

    // Size returns the display dimensions in pixels.
    Size() (x, y int16)

    // Display flushes buffered data to the hardware (no-op for direct-write displays).
    Display() error
}

Any struct that satisfies these three methods can be passed to tinyfont.WriteLine. The TinyGo drivers package provides ready-made implementations for most common displays.

Multi-line text

For displays with limited height, you can call WriteLine multiple times advancing y by the font’s line height:

lineH := int16(10)
y := lineH
for _, line := range strings.Split(text, "\n") {
    tinyfont.WriteLine(disp, &tinyfont.TomThumb, 2, y, line, white)
    y += lineH
}

Font tester

Try out the built-in fonts directly in the browser. The widget below runs the same rendering code you would use on a real microcontroller, compiled with TinyGo to WebAssembly.

Loading WASM…

⚠️ WASM binary not found. Run ./build-wasm.sh to build it.

Select a font, adjust colors, choose a display size, and type your text to preview exactly how it will look on the target hardware.

docs