Feature Library

World lettering: painted signs and crisp scene text (engine-free)

3.17 GPU · 0.42 CPU ms
A still of the World lettering: painted signs and crisp scene text (engine-free) demo
Still
The live demo starts when it’s in view.Type the wall’s sign · wear and overspray · views: Yard, Plate, Livery, Road · drag to look round

The HaTac engine’s two text parts, lifted whole and engine-free.

Surface text bakes a sign, a livery, a stencil or a machine label into a colour tile and a separate letter-coverage tile in one shared atlas, painted once with Canvas 2D (in a worker too) and lit, scratched and roughened by the receiving surface like any paint: lines in metres with their own family, weight, colour, alignment and tracking, shrink-to-fit or wrap with a fit report, plates with borders, stencil bridges cut from every enclosed counter, seeded overspray, three isolated mips per tile, identical wordings sharing one tile by content hash, leases that repaint in place when sole and detach when shared, and font loads that repaint without moving the UVs. MSDF text reads TrueType and CFF fonts from their bytes (kerning from kern and GPOS), lays out lines with wrapping and basic right-to-left runs, builds an edge-coloured multi-channel distance atlas with a true-distance channel, and draws labels in one instanced pass per page, on the screen, as billboards or on a surface, depth-tested, with outline, glow and shadow, sharp at any zoom. A small host gives a plain WebGPU page the shared frame group, a reverse-Z camera and the paint snippet. No three.js, no dependencies.

What it costs a frame

3.17 ms
0.42 ms
GPU
3.17 ms
CPU, median
0.42 ms
CPU, 95th pct
0.80 ms
Draw calls
0
Weight
Heavy

Measured 29 November 2026 on RTX 4060 Laptop, 13th Gen Intel(R) Core(TM) i9-13900H, Chrome 158, 1920×1080 at 1×. 600 frames × 3 rounds, median kept (rounds ranged GPU 3.16–3.27, CPU 0.39–0.43 ms). What ran: Alone: one painted plate (a 1.2 × 0.48 m surface-text panel at 420 px/m, its colour and letter mask from one 2048² atlas page with three mips) on a steel backing, lit by the sun with distance-field soft shadows; MSDF text in the three placements (a surface display, a billboard and a screen caption, about 60 glyphs from one 512² page of Bitstream Vera), depth-tested, 4× multisampling at high. Phones: tiers are being measured next.

How steadily it runs on RTX 4060 Laptop · 13th Gen Intel(R) Core(TM) i9-13900H · reference

Typical frame ?
16.88 ms
1% low ?
55 fps
Varies by ?
±0.48 ms
All metricsRTX 4060 Laptop · 13th Gen Intel(R) Core(TM) i9-13900H · reference
p50p95p9916.04 ms18.25 ms +
How long each frame took. Most frames sit in the tall bars; a long tail to the right is hitching.

Frames run on a 60 Hz timer (a page demo), so most frames take about one tick, 16.7 ms: the spread around it is what matters.

Frames

Median (p50) ?
16.88 ms
p95 ?
17.77 ms
p99 ?
18.06 ms
Slowest ?
18.48 ms
Mean ?
16.90 ms
Standard deviation ?
0.48 ms
1% low ?
55 fps
0.1% low ?
54 fps
Hitches ?
0 of 600
Over budget ?
0 of 600

Main thread

Long tasks ?
0
Long frames ?
0
Event-loop delay ?
0.1 / 0.7 / 1.8 ms

Input

No input during this run.

Memory

JavaScript heap ?
34.3 → 33.7 MB
Growth ?
-0.61 MB

Browser

JavaScript a frame ?
0.49 ms
All tasks a frame ?
1.14 ms
Layout / style ?
0.02 / 0.01 ms
Main thread busy ?
7%

Garbage collection

Collections ?
3 (2 minor, 1 major)
Pauses ?
8.1 ms in all, longest 1.9

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
NothingNo other packages
With an agent
install("world-lettering")Your coding agent reads its pitfalls and installs it through the library’s MCP server. Set it up

What it’s for

  1. A game or a digital twin whose machines, containers, doors and roads carry their own painted names and numbers, scuffed and lit like the paint around them
  2. A livery or a sign a player edits live (a ship’s name, a shop sign, a team number) repainted into the same tile as they type, shrunk to fit
  3. Stencilled cargo markings with real bridges and sprayed edges, deterministic from a seed so every client paints the same
  4. Thousands of placements of a few wordings (crate numbers, bay signs) sharing their tiles: one upload each, not one per object
  5. Crisp readouts floating over a scene (a value over a machine, a name over a unit), sized in metres, hidden behind walls by the depth buffer
  6. Chart axes, HUD numbers and captions drawn inside the canvas at any zoom or angle, with outlines and glow from one atlas
  7. Text from any TrueType or CFF font file without a font toolchain: parsed, kerned and turned into a distance atlas in the browser or a worker

Pitfalls, in brief

  1. The demo needs WebGPU to draw its yard and the MSDF labels (storage buffers, a depth-tested label pass).
  2. Supply the fonts and their licences: the module ships none.
  3. Keep a lease until the last draw that uses its tile has been submitted: a released rectangle can take new wording at once.
  4. Read the tile’s page and UVs again after update(): editing a shared wording detaches that placement to another tile (another page, possibly).
  5. A panel that must shrink can throw “cannot fit at one raster pixel per em” in the engine’s copy even when it fits: the shrink search starts at 1 ÷ (sizeM × pixelsPerMetre), and that times sizeM × pixelsPerMetre can round to 0.9999999999999999 (0.06 m at 420 px/m), which the floor refused.
13 more in brief
  1. A stencil’s bridge width is one per panel, not per line: a bridge sized for a 0.6 m headline cuts a 0.15 m line’s 0, 4 and 8 into other letters (the demo’s first livery read “3R 4RR”).
  2. Wear the letters with the mask texture’s alpha, never the colour’s: the colour’s alpha covers the whole plate when the substrate is opaque.
  3. Sample with the atlas’s own sampler and keep a panel’s UVs inside [0, 1]: extra anisotropy, or sampling past the panel, reaches past the four-texel gutter into the neighbour.
  4. Each page pair (colour and mask, three mips) costs 42 MiB and is allocated on first use; pages stay until dispose().
  5. Bake big batches while loading: the engine measured 200 distinct panels at 1.23 s (paint, pack, three mips, upload).
  6. Build the MSDF atlas off the critical path: the 95 printable ASCII glyphs took 98 ms cold.
  7. setLabels replaces every label and glyph buffer: call it when text changes, not every frame (the demo rebuilds its readouts twice a second).
  8. Size the distance range for the widest effect: outline, glow and shadow offset together must stay within half the range (0.125 em for the default 8-texel range at 32 texels/em), or setLabels throws.
  9. Pass the target-to-CSS pixel ratio for screen labels (the canvas’s width over its CSS width, render scale included), not devicePixelRatio alone.
  10. Give the label pass the scene’s own reverse-Z depth (depth32float, cleared to 0, compared greater) with the same sample count, and its colour target loaded, not cleared: it composites premultiplied over the picture.
  11. Draw into an sRGB view (the canvas format plus -srgb as a view format): the label colours and the painted panel are linear, and blending premultiplied linear colour into a plain unorm target darkens every edge.
  12. Mirror every meaningful label on the page (an off-screen list, a live region where it matters): the GPU draws quads, and a screen reader reads only the DOM.
  13. Shape complex scripts elsewhere: MSDF layout reorders Hebrew and Arabic runs and keeps marks with their base, but does not join Arabic letters, apply ligatures or run full bidi; supply a shaped TextLayout and keep the string for accessibility.
18 pitfalls in full, the hook-up guide, the module source and its tests come with the part.

Where it comes from

From HaTac. Adapted from published work, named below.

Hannes Andersson: The HaTac engine’s surface-text and msdf-text modules, their recipe kind, decisions, tests and measurements; the library’s host and demo.

Viktor Chlumský, msdfgen and Shape Decomposition for Multi-channel Distance Fields (2015): The multi-channel distance field the atlas builds (edge colouring, the median reconstruction); the engine’s README cites it as the reference.

Bitstream, Inc., Bitstream Vera Sans: The font the demo’s MSDF labels and the ported tests read; free to redistribute under the Bitstream Vera licence (demo-fonts/bitstream-vera-license.txt).

The Inter Project Authors, Inter: The demo’s painted sans (SIL OFL 1.1, demo-fonts/inter-OFL.txt).

The JetBrains Mono Project Authors, JetBrains Mono: The demo’s stencil and plate mono (SIL OFL 1.1, demo-fonts/jetbrains-mono-OFL.txt).

Third-party terms ship with it in NOTICE.md.

textletteringsignagesignliverydecalstencilstencil bridgesoverspraymachine labelenamel plateroad markingpainted textbaked texttexture atlasletter maskcoverage maskwearscratchesroughnesscanvas 2doffscreencanvasworkershrink to fit

Near it in the frame