term.gfx.font

index · term.gfx

Overview

Pixel-art text — render strings as scaled bitmap glyphs onto a canvas.

A font is a table of monochrome glyph bitmaps (rows of #/.) with a fixed cell size.

Each glyph is baked once into a white alpha-mask sprite (cached per character + scale) and blitted with the draw colour folded in as a tint, so the same cached mask renders in any colour without re-rasterizing.

This builds directly on term.gfx.sprite (art masks) and canvas:blit (tinted compositing).

Functions

NameSignature
fontfont(spec) -> font

font(spec) -> font

Create a pixel-art font

spec table fielddefaultdescription
glyphsmap char -> bitmap rows of #/.
cell_w/cell_hglyph cell size in pixels
default_colorRGBA, default near-white
fallback char to draw for missing glyphs, default space
spacing1gap between glyphs in source pixels
line_spacing1gap between lines in source pixels

With no glyphs, the bundled default 5x7 ASCII font is used. Lowercase letters fall back to their uppercase glyph.