What problem does it solve?
Pretext enables DOM-free measurement and layout of multiline text to power expressive, text-driven demos in the browser, freeing you from DOM reflows while keeping precise line metrics and per-glyph positioning.
Core Features & Use Cases
- DOM-free measurement of lines, widths, and per-glyph positions to feed custom renderers (canvas/WebGL) and interactive typography.
- Text-around-obstacle layouts: drive text flow around moving sprites or shapes for kinetic typography and editorial effects.
- Flexible demo templates: produce single-file HTML demos that showcase creative typography with real prose and ASCII-like visuals.
- Use Case: build a dynamic title card where lines wrap around a floating orb or logo, with exact glyph coordinates for effects.
- See templates and references for patterns and ready-made demos.
Quick Start
Create a single-file HTML demo by importing pretext from esm.sh, calling prepareWithSegments on your text and font, then using layoutNextLineRange or layoutWithLines to render onto a canvas.