lithosphere

a typesetting engine for game text

Line breaking for the words inside a game: dialogue boxes, signs, item descriptions. Instead of filling one line at a time, it looks at the whole paragraph before deciding where each line ends, so the spaces between words come out more even. It is made for pixel fonts, and it is quick enough to re-flow the text whenever a box changes size.

Very early: it started on 2026-10-22. Its first user is the dialogue box in tunacan, our game engine, which the Grocery Harrison game in progress talks through.

the technical version

Line breaking for the words inside a game: dialogue boxes, signs, item descriptions. It uses the Knuth-Plass method from TeX, which compares the possible breaks across the whole paragraph instead of filling one line at a time, so the spaces come out more even. It works on whole pixels and reads pixel fonts made in font//litho, our pixel font editor, directly.

A game can re-break a paragraph every time the box changes size. It is portable C99 that never allocates, and the same code runs in a browser, on a desktop and on the Wii.

Very early. It started on 2026-10-22, and the four milestones done so far are the engine, hyphenation, the web build and a Wii demo. Since then it has learned centred and right-aligned lines, marks a talk box can act on as it reveals the text (a pause, a reading speed, a colour), and words set in a second font. tunacan's dialogue box is the first thing built on it.

try it

first fit

total fit

edit the text

The same paragraph, justified two ways by the engine running in this tab. First fit is what an ordinary word wrap does: fill each line, then spread its spaces. Total fit picks every break together. marks a space stretched past its natural width; the darker it is, the more it was stretched. Untick hyphenate to see how much the hyphens are buying.

what's here

the breaker Total fit on an integer grid, plus first fit beside it for comparison, with emergency stretch for faces too small to justify otherwise
the font reader Reads font//litho's faces directly, kerning and all, so no rasteriser comes in between
hyphenation Liang's patterns from TeX Live, packed into a committed trie, plus a game's own exception list so names break where they should
strikes A face packed into C for consoles: metrics, kerns and one-bit bitmaps, linked in and never parsed
the wasm build One self-contained script with the engine inside, which runs the demo above and the debug view
golden files Fourteen recorded settings that gcc, MSVC, emcc and the Wii's compiler all have to reproduce exactly

what a re-break costs

Re-flowing a paragraph is quick enough to do whenever the text changes: about 3% of one frame on a Wii, measured in an emulator, and 5 to 20 millionths of a second in a browser.

Wii, in Dolphinabout 300 µs on average for building the paragraph and running total fit, 563 µs at worst: around 3% of a 60 Hz frame. That is Dolphin's emulated clock; the demo has not run on a console yet
V8about 5 µs for a short dialogue line, about 20 µs for a hyphenated paragraph. The demo above measures it again in your browser

the name

After Lithosphere by Texas Hold’Em Lava Dome. It has nothing to do with magmascript, even though magmascript's memory tier is called the Asthenosphere.

PolyForm Noncommercial 1.0.0 · Copyright 2026 magmacrunch media · Litho Display and Litho Mono under the SIL Open Font License 1.1

// source access //

lithosphere is developed in-house and its source is not public. The compiled engine on this page is the same build the tests run against.

For source access, licensing, or anything else, email info@magmacrunch.com.