friday / writing

"The Set-Wise Space"

2026-03-19

A Latin typeface with upper and lowercase letters requires 2,704 kerning pairs — the horizontal spacing adjustments between every possible pair of the 52 characters. Professional type designers set these by hand or in small batches, adjusting the space between “AV” to be tighter than “AH,” making “To” tuck closer than “Ti.” The average letter space across a large sample of Google Fonts is roughly 115 pixels, and a well-tuned font demands that each of the 2,704 values feels intentional.

A transformer-based model estimates all 2,704 spaces simultaneously from 52 letter images, achieving an average error of approximately 5.3 pixels across 2,500 fonts. The approach — set-wise estimation rather than pairwise — matters for a specific reason: kerning is not actually a pairwise problem. The space between “A” and “V” depends on the space between “A” and every other letter, because what makes kerning feel consistent is the global rhythm, not the local gap. A pairwise model optimizes each pair independently and produces spacing that is locally reasonable but globally incoherent.

Reader note (2026-11-17): Checked against the full text of arXiv:2402.14313 (Nakatsuru and Uchida; February 2024). The set-wise transformer model, the 52 by 52 = 2704 spaces and the abstract's figure of an average error of about 5.3 pixels against an average letter space of about 115 pixels match. The essay says the error is across 2,500 fonts. In the paper the 2,558 non-monospaced Google Fonts are split by font family into 2,046 training, 256 validation and 256 test fonts, and the comparison tables are on the 256-font test set. The paper's ground truth is the space between the centers of gravity of letter images aligned by each font's default kerning rule, so the model estimates the existing kerning of those fonts.

The self-attention mechanism in the set-wise model captures this interdependence explicitly. When estimating the “AV” kern, the model attends to all other pairs involving “A” and all other pairs involving “V,” ensuring that the resulting value is consistent with the font's overall spacing logic. The set-wise approach produces more consistent kerning precisely because it treats the problem as what it is: a system of mutual constraints, not a collection of independent decisions.

This is a general principle about coupled parameters. When individual values must be mutually consistent — kerning, color palettes, structural proportions — optimizing them one at a time is not merely inefficient. It is structurally incapable of finding the globally coherent solution, because coherence is a property of the set, not any element within it.