Lesson 5 of 9 · 22m
Font Loading Without Invisible Text or Layout Chaos
Control font formats, subsets, preloading, display behavior, and metric fallbacks so typography is fast, legible, and stable.
Fonts look small in a bundle report until they block text, move navigation, or turn a menu into a different width after the user already tried to tap it. Typography is performance-critical because text is usually the content. The goal is not 'load the brand font.' The goal is to render readable text quickly and transition to final typography without visual violence.
WOFF2 is the baseline; everything else needs a reason
Use WOFF2 for web delivery. Do not ship TTF or OTF because that is what the design folder contained. A modern @font-face declaration is narrow:
@font-face {
font-family: "Inter";
src: url("/fonts/inter-latin-400.woff2") format("woff2");
font-display: swap;
}Variable fonts can reduce file count, but they are not automatically smaller. One well-subset variable font may beat six static files; one enormous variable font may be worse than two carefully used static weights.
Subset because most pages do not need the world
A full font can contain scripts and glyphs your interface never renders. Subset to the language coverage you actually serve:
pyftsubset inter.ttf --output-file=inter-latin.woff2 --flavor=woff2 --unicodes="U+0000-00FF,U+2000-206F" --layout-features="kern,liga"This is powerful and dangerous. If you subset Latin-only and later render customer names, Japanese support tickets, or mathematical symbols, fallback behavior appears in production. Keep the unicode range and product language requirements in the same review conversation.
Choose font-display as a user-experience decision
block brief invisible period, then swap; risky for text-first pages
swap fallback immediately, custom font later; fast but can shift
fallback short block, limited swap window; conservative compromise
optional use custom font only if quickly available; best for constrained networksFor most content sites, swap or fallback is safer than invisible text. For a reading-heavy product on unreliable networks, optional is often the adult choice. Brand consistency does not matter if users cannot read the page.
Preload only fonts the first render truly uses
If the primary body font is necessary for first paint and discovered through CSS, preload it:
<link rel="preload" href="/fonts/inter-latin-400.woff2" as="font"
type="font/woff2" crossorigin>Font preloads require crossorigin even on the same origin because font fetches use CORS mode. Do not preload five weights. Preloading too much tells the browser your decorative font matters as much as the HTML, CSS, and hero image competing for bandwidth.
Prevent layout shift with better fallbacks
When a custom font swaps in, line lengths and element heights change. Modern metric overrides can reduce that movement:
@font-face {
font-family: "Inter Fallback";
src: local("Arial");
size-adjust: 96%; ascent-override: 92%; descent-override: 24%;
}
body { font-family: "Inter", "Inter Fallback", system-ui, sans-serif; }Getting these numbers right requires visual testing. The win is not theoretical: navigation width, card height, and paragraph line breaks stay closer to final shape, reducing CLS and the perception of instability.
Field notes
- Fonts are render-impacting even when they are small; treat them as critical-path dependencies, not decorative assets.
- Check italic and bold synthesis. Browser-synthesized obliques look bad and can change metrics.
- Icon fonts are an accessibility and rendering liability; inline SVG is usually the better modern default.
- Test with cache disabled and slow CPU. Font problems disappear on a developer workstation long before they disappear for users.
Was this lesson helpful?