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.

Ship faster than your competition

Focus on customers and sales while we handle product delivery. Hire a dedicated AI maker or a whole product team.

Launch new products
Fix your delivery
Hit fundraising milestones
© 2026 Paralect, Inc 651 N Broad St, Suite 206, Middletown, 19709, Delaware, United States