DEV Community

BM lm
BM lm

Posted on

font-display explained: FOUT, FOIT, and the fallback metrics trick

Every web font takes time to download. What the browser shows WHILE downloading is controlled by one CSS property - and choosing wrong is the difference between a smooth page and a jump-scaring layout.

The three behaviors

font-display: block (FOIT era): hides text entirely for up to 3 seconds while the font loads. Invisible content, then a pop-in. The default in older setups and the worst reading experience.

font-display: swap: shows the fallback instantly, swaps when the real font arrives. Content is readable immediately - but the swap causes a visible flash and (without help) a layout shift.

font-display: optional: gives the font ~100ms. If it loads in time, use it; otherwise the fallback stays for the ENTIRE page view. Best for repeat visitors, worst for first visits (the font rarely wins the race on a cold cache).

The fallback metrics trick

swap's problem is the size mismatch: the fallback (Arial) occupies different space than the real font (say, Foundry Grotesque), so text reflows when the swap happens. Modern CSS fixes this:

@font-face {
  font-family: 'Foundry Grotesque';
  src: url('foundry.woff2') format('woff2');
  font-display: swap;
  ascent-override: 95%;
  descent-override: 25%;
  line-gap-override: 0%;
  size-adjust: 102%;
}
Enter fullscreen mode Exit fullscreen mode

With size-adjust and the metric overrides tuned, the fallback renders in almost exactly the same footprint as the real font - the swap becomes invisible.

The audit step nobody does

Before tuning metrics, you need to know what the fallback is being asked to imitate - which means knowing what the real font is. On teams with long-lived codebases, that knowledge is often gone. Screenshot the rendered page and identify it on-device: Typeye names the typeface from a screenshot entirely in your browser, no uploads of production pages needed.

The default that wins

swap + tuned fallback metrics. optional for fonts that are pure decoration. block almost never (it holds text hostage).

One property, tuned deliberately, and the font-loading experience goes from jump-scare to invisible.

Top comments (0)