Pretext · Simon Willison's Weblog
Science, Technology & Innovation · Mar 29, 2026
Pretext implements multilingual segmentation and browser-aware wrapping that approximates real browser layout across mixed scripts, emojis, and edge cases, enabling more accurate, single-engine text layout for global, user-generated content.
Pretext · Simon Willison's Weblog
Science, Technology & Innovation · Mar 29, 2026
Pretext speeds up browser text layout by running a one-time prepare() that measures text segments on an off-screen canvas and caches those metrics, then using cheap repeated layout() calls to emulate word wrapping and compute line counts/heights without DOM measurement—making interactive, width-dependent text effects practical.
Pretext · Simon Willison's Weblog
Science, Technology & Innovation · Mar 29, 2026
Pretext validated its layout estimator against corpus-scale “browser truth” by rendering large, multilingual documents (e.g., the full Great Gatsby and long Thai/Chinese/Korean/Japanese/Arabic texts) across browsers and widths and iteratively calibrating models (via Claude Code/Codex) to match real browser outputs, implying builders should use corpus-level diff testing against browser rendering rather than isolated short-English unit tests.
Pretext · Simon Willison's Weblog
Science, Technology & Innovation · Mar 29, 2026
A tiny client-side library (Pretext) shifts text measurement from costly DOM reads to off-screen preprocessing, caching, and browser-quirk-aware wrapping emulation—making repeated measurements much faster and enabling new text-heavy UI features with minimal bundle overhead.