Text measured by CSS for signs, labels and particles

Type in the field at the bottom of the picture. It's a real <input> drawn by the canvas. Each character you type grows into place and a copy flies up to the sign, and each character you delete breaks into pieces. The canvas knows where each character is from input.createValueRange(). The sign, the book spines and the ticker are elements sized by text-fit and text-box-trim, drawn at the size CSS gave them.

Open late

Go

Typography

Paint

Hit testing

CSS

text-fit · text-box-trim · sideways-lr · createValueRange() ·

Show the code CSS sizes the labels, OpaqueRange finds the characters
  1. The markup. One canvas. The labels and the input are its children.
  2. The labels, in CSS. No script measures them.
  3. Drawing a label. The element's own size is the size of the texture.
  4. One rectangle per character of the input.
  5. What changed. On each input event the old and new values are compared. Deleted characters are cut out of the last picture of the field.
  6. Drawing the characters. Each piece is a part of the field's own picture, drawn again somewhere else.
  7. Without createValueRange(). The same rectangles from measureText().
  8. The whole module.

How it works

Live checks

Each check builds a small canvas of its own in a corner of the window. The picture above isn't touched.

ResultExperimentDetail

Findings

From Chromium 157 with software rendering. The rows above say what your browser does.