Prætextus
Demonstratio Typographiæ Computatæ
DOM-free text layout — measured once, arithmetic ever after
prepare() segments the text and measures each unit via canvas — once. layout() is thereafter pure arithmetic over cached widths: no DOM reads,
no canvas calls. Drag the slider; the height updates without touching the DOM.
Don Quixote · Miguel de Cervantes · 1605
↑ Pure arithmetic. Zero DOM reads on resize.
prepareWithSegments() + layoutNextLine() place each line
individually on canvas, SVG, or WebGL. The drop cap here uses a narrower available
width for the first rows, then widens automatically — all via the same streaming cursor.
layoutNextLine() lays out one row at a time, letting each line's
available width change independently. As the astrolabe orbits, each line is
re-broken around wherever the obstacle happens to be — left, right, or centre.
walkLineRanges() returns each line's width without building text strings.
Here it finds the tightest container that still fits each quote — the "shrink-wrap"
that CSS has always lacked for multiline text, across any script.