Canvas & 2DSDF text at any zoom
Crisp text at 2% or 6400%: glyphs rasterised on first use with Canvas 2D, turned into signed distance fields by an exact distance transform, packed into one…
What it costs a frame
- GPU
- 0.09 ms
- CPU, median
- 0.41 ms
- CPU, 95th pct
- 0.54 ms
- Draw calls
- 4
- Weight
- Light
Measured 3 November 2026 on RTX 4060 Laptop, 13th Gen Intel(R) Core(TM) i9-13900H, Chrome 156, 1920×1080 at 1×. 600 frames × 3 rounds, median kept. What ran: Measured while the board zooms slowly in and out over about 900 glyphs (one instanced draw). Phones: tiers are being measured next.
| Machine | GPU ms | CPU ms | CPU p95 |
|---|---|---|---|
| RTX 4060 Laptop · 13th Gen Intel(R) Core(TM) i9-13900Hreference · measuring tool | 0.09 | 0.41 | 0.54 |
| apple · Apple A19 Proin a browser tab · 16 November 2026 | 1.66 | 0.34 | 0.72 |
| Intel Arc 140V (Xe2-LPG) · Intel Core Ultra 7 258Vin a browser tab · 15 November 2026 | 0.39 | 0.98 | 1.31 |
Bars against one 16.7 ms frame. A browser-tab run is timed in a visible tab without the tool’s scripted input, so read it as close, not exact.
What it needs
- Renders with
- WebGPUNeeds WebGPU: current Chrome and Edge, Safari 26+, Firefox 141+ on Windows.
- Your browser
- Checking…Looking for WebGPU
- Depends on
- three.js 0.187.0No other packages
What it’s for
- Text on zoomable boards
- Labels in 3D scenes and maps
- Sticky notes that fit their text
- Thousands of labels in one draw
- Editors that must wrap like the DOM
Pitfalls, in brief
- Load the font before making the atlas (document.fonts.load): a face made earlier measures and draws the fallback font, and its layout will not match the DOM later.
- The atlas doubles when it fills: every glyph’s cell is a share of the texture, so rasterise all of a run’s glyphs before computing cells (GlyphText.set does), and point the material at the new texture (growListeners).
- Coverage from the field’s screen derivative (fwidth) gives one-pixel edges at any zoom; a fixed smoothstep width blurs when zoomed in and aliases when zoomed out.
- Partly covered pixels sit between the inside and outside transforms, so the edge lands where the antialiasing put it: run the transform on the coverage, not a thresholded bitmap.
- The quad is the bitmap plus a 6 px buffer: the field needs room to fall off, so glyphs overlap their neighbours’ quads (draw text with depthWrite off).
1 more in brief
- Wrapping matches the DOM only with the same font, weight, kerning (normal) and line height (1.3 here): set the editor’s CSS from the same constants.
Where it comes from
From SpaciousPro. Fully custom code.
Felzenszwalb & Huttenlocher, Distance Transforms of Sampled Functions (2012): The exact Euclidean distance transform the field is built with. The algorithm, implemented from the paper.


