Measure multiline text without touching the DOM
Pretext (@chenglou/pretext) uses the browser font engine for ground-truth widths, then does line breaking and height math in pure data—great for virtual lists, Canvas text, and stable layouts.
Performance
prepare() measures once; layout() re-runs in microseconds for new widths.
Capabilities
Many languages, emoji, mixed bidi; optional pre-wrap; line-by-line APIs for Canvas and ragged widths.
Open source
MIT licensed at chenglou/pretext. pretextonline is maintained separately.