Guides/4 min

Tracking is not a canvas property

letter-spacing exists in CSS. On canvas you advance the pen yourself.

CanvasRenderingContext2D has font, textAlign, textBaseline, and (in newer engines) letterSpacing and fontKerning. Support is uneven, and you still need a fallback for production ads that must render identically in last year’s Chrome.

The reliable method is to draw glyph by glyph:

let x = origin;
for (const ch of line) {
  ctx.fillText(ch, x, y);
  x += ctx.measureText(ch).width + tracking;
}

If textAlign is center or right, measure the tracked width first and shift the origin. CanvasFont’s renderer does this, and the exported snippet does too.

Kerning

measureText(ch).width on a single glyph does not include kerning against the next glyph. Drawing character-by-character therefore drops kerning. For display type with open tracking that is fine (tracking dominates). For running text at 0 tracking, prefer a single fillText of the whole line so the shaper can kern.

Rule of thumb used in the studio: if tracking is 0, draw the line in one call; if tracking is not 0, draw glyphs.