chenglou/pretext: Fast, accurate & comprehensive text measurement & layout ·
github.com · 2,986 words · saved by 2 readers
Fast, accurate & comprehensive text measurement & layout
Pure JavaScript/TypeScript library for multiline text measurement & layout. Fast, accurate & supports all the languages you didn't even know about. Allows rendering to DOM, Canvas, SVG and soon, server-side. Pretext side-steps the need for DOM measurements (e.g. getBoundingClientRect, offsetHeight), which trigger layout reflow, one of the most expensive operations in the browser. It implements its own text measurement logic, using the browsers' own font engine as ground truth (very AI-friendly iteration method). Installation npm install @chenglou/pretext Demos Clone the repo, run bun…
saved by
related reading
- Pretext - Text measurement that never touches the DOM.pretextjs.dev
- Cheng Lou on X: "My dear front-end developers (and anyone who’s interested in the future of interfaces): I have crawled through depths of hell to bring you, for the foreseeable years, one of the more important foundational pieces of UI engineering (if not in implementation then certainly at https://t.co/BKnwCDIp75" / Xx.com
- Pretext Demoschenglou.me
- Impeccable: The missing upgrade to Anthropic's impeccable skillimpeccable.style
- Agentationagentation.dev
- DESIGN.md Examples for AI Agents | Refero Stylesstyles.refero.design
- UI Skills for Design Engineers | UI Skillsui-skills.com
- Subframe – The AI design tool built for codesubframe.com
- Wonder — What you see is what you shipwonder.design
- ui.sh — Agent skills for interface buildersui.sh
- Agentationagentation.com
- Text Rendering Hates You - Faultlorefaultlore.com