Pretext

Fast text measurement and layout without DOM reflow

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.

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.

© 2026 Paralect, Inc 651 N Broad St, Suite 206, Middletown, 19709, Delaware, United States