The font-display values
| Value | Behaviour |
|---|---|
block | a short invisible-text period, then swap |
swap | fallback font at once, swap after load |
fallback | a very short block, limited swap period |
optional | font used only if it loads very quickly |
auto | the browser decides, usually like block |
For body text swap or fallback are the usual choices. optional is useful where layout stability matters more than guaranteed use of the font.
Where layout shift comes from
When the fallback is replaced by the main font, letter widths and line heights change. Blocks reflow and elements below them move. This is measured by CLS (Cumulative Layout Shift); the recommended “good” threshold is 0.1 or less.
Align the metrics
The size-adjust, ascent-override, descent-override and line-gap-override descriptors let you declare a fallback that imitates the proportions of the main font:
@font-face {
font-family: "Literata Fallback";
src: local("Georgia");
size-adjust: 104%;
ascent-override: 92%;
descent-override: 24%;
line-gap-override: 0%;
}
The values above are an example. Derive your own by measuring the actual rendering, because they depend on the font pair and platform.
Do not promise “zero shift” until you have measured. Test on a slow connection with the cache disabled.
