Pure TypeScript · No DOM · No Reflow

Userland Text
Measurement Engine

Fast, accurate, comprehensive text measurement in pure TypeScript — for laying out entire pages without CSS, bypassing DOM measurements and reflow entirely.

"Have crawled through depths of hell to bring you, for the foreseeable years, one of the more important foundational pieces of UI engineering — fast, accurate and comprehensive userland text measurement algorithm in pure TypeScript."

Text Input Measuring live · zero DOM
Full width px
Characters
Wrapped lines
Time μs
Canvas Layout — Coordinates from TypeScript, not CSS x/y computed in JS
text-measure.ts
Performance Benchmark

Measures how many 10-word strings each method can measure per second. All on the main thread — reflects real layout engine cost.

🔴 TypeScript table lookup (this engine)
🔵 Canvas measureText() — raw
⚪ DOM getBoundingClientRect — reflow
Announcing Ball — character positions from metrics table Animating
Controls

The ball knows the exact x/y of every character because of the GlyphMetrics table. Without it, you'd have to query the DOM for each position — causing reflow on every frame.

Controls
Effect
Layout
Animation
Effect Settings
Text

Every character's position is computed from the GlyphMetrics table — enabling physics-accurate animations without querying the DOM once.

Draggable · Live Code
Masonry Layout Engine
layout-engine.ts — live ● LIVE

      
Selected text 0 chars
Click and drag over the text to select…

Hit-testing maps any (x,y) to an exact character index using the GlyphMetrics width table. No DOM selection API — the same primitive that powers every code editor and PDF reader.

Edit inline text
Use tokens: {check} {star} {warn} {ai} {arrow}

Each token is treated as a glyph with a fixed width. The layout engine allocates exact space for it, then the renderer draws a custom canvas element at that position — the same technique Slack uses for inline emoji.

Word target positions come from the layout engine. Spring physics animate each chip to its correct slot. Drag any chip — it snaps back when released.

Text wrap · drag the card
Edit wrap text

The wrap algorithm checks each line's Y range against the card's bounding box. Overlapping lines are split into left and right zones — each measured independently with the GlyphMetrics table. At 60fps, no rendering pipeline is touched.