Pretext is a TypeScript library for multiline text measurement and layout that bypasses the DOM entirely. It uses canvas
measureText for font shaping in a one-time prepare() pass, then computes height, line count, and line breaks as pure arithmetic via layout() — no getBoundingClientRect, no reflow.Supports variable-width containers (text flowing around floats), rich inline text with mixed fonts, CJK, Arabic, bidi, soft hyphens, emoji, and
white-space: pre-wrap mode. Works for rendering to Canvas, SVG, and WebGL.DOM-Free Layout
No reflow — text height from pure arithmetic after one-time measurement
Line-by-Line Control
Variable-width lines for flowing text around floats and custom layouts
Rich Inline Text
Mixed fonts, mentions, code spans, and chips with proper whitespace collapse
Broad Language Support
CJK, Arabic, bidi, soft hyphens, grapheme clusters, emoji
Hire a Claude Code developer who ships with AI agents
Meet 2-3 vetted profiles in 48 hours, then test 1 on a real task in a 2-day trial for $7. From $30/h, no contract.







