Web Performance • Core Web Vitals
Font Fallback Generator (CLS & size-adjust Matcher)
Create metric-adjusted @font-face fallback rules for Inter, Roboto, Playfair Display, Merriweather, and custom webfonts to keep Cumulative Layout Shift near zero.
@font-face {
font-family: "Inter Fallback";
src: local("Arial");
size-adjust: 107.00%;
ascent-override: 90.40%;
descent-override: 22.50%;
line-gap-override: 0.00%;
}
:root {
--font-primary: "Inter", "Inter Fallback", sans-serif;
}
body {
font-family: var(--font-primary);
}CSS @font-face Metric Override Descriptors
| Descriptor | What It Controls | CLS Impact |
|---|---|---|
size-adjust | Scales glyph widths and em-box uniformly | Prevents horizontal line-wrap changes |
ascent-override | Height above the baseline | Matches vertical line-box top |
descent-override | Depth below the baseline | Matches vertical line-box bottom |
line-gap-override | Extra default leading between lines | Eliminates paragraph height drift |
Related Accessibility & Performance Tools
Frequently Asked Questions
How does a CSS font fallback generator reduce Cumulative Layout Shift (CLS)?
When a webfont finishes downloading, it often has a different character width and vertical line height than the temporary system font (like Arial or Times New Roman), causing paragraphs to reflow. By applying size-adjust, ascent-override, descent-override, and line-gap-override to a local @font-face rule, the fallback font matches the webfont's bounding box before swap.
Which browsers support size-adjust and ascent-override?
Chrome, Edge, Firefox, Safari (17+), and Opera all support @font-face size-adjust and metric override descriptors. Older browsers safely ignore unsupported descriptors and still render the local fallback font.
What is the difference between size-adjust and font-size?
size-adjust scales the glyph metrics of a specific @font-face without changing the computed CSS font-size property. That keeps em, rem, and line-height calculations consistent across both the fallback font and the final webfont.
Do I still need font-display: swap when using a matched fallback font?
Yes. Pairing font-display: swap (or optional) with a metric-matched fallback font gives visitors immediate readable text while minimizing visible jump when the webfont swaps in.