chenglou/pretext
6 articles
Prerequisites
- ›Basic web development and DOM concepts
- ›CSS text layout model (white-space, overflow-wrap)
- ›Familiarity with TypeScript type system
Pretext Architecture: Why Two Phases Beat DOM Measurement
Explores the core architectural insight behind Pretext: separating one-time text analysis from pure-arithmetic layout computation
Inside the Text Analysis Pipeline: From Raw String to Measured Segments
Deep-dives into whitespace normalization, Intl.Segmenter, the merge cascade, and Canvas measurement that transform raw text into parallel arrays
The Line Breaking Engine: Fast-Path Arithmetic and Browser Parity
Dissects the line-breaking engine in line-break.ts, the hot path executing in microseconds with simple vs full walker dispatch
Browser Quirks, Emoji Correction, and World Script Support
Covers cross-browser engine profiles, emoji width correction, the segment metric cache, bidi implementation, and world script handling
Rich Layout APIs in Action: Shrinkwrap, Obstacle Routing, and Editorial Spreads
Explores the rich tier of Pretext's API through chat bubble shrinkwrap, editorial obstacle routing, and SVG polygon hull extraction
Validating Text Layout: Corpora, Browser Sweeps, and Accuracy at Scale
Examines Pretext's testing infrastructure: deterministic fake canvas, browser accuracy sweeps, multilingual corpus validation, and RESEARCH.md as institutional memory