Matching Fallback Font Metrics
What you'll learn: How to calculate and apply precise metric overrides so your fallback font renders at nearly identical dimensions to your web font.
The Core Problem
When a web font loads late or fails to load, the browser displays a fallback font (like Arial or Georgia). Even if you've used size-adjust to match the overall size, subtle differences in how fonts are drawn vertically can still cause layout shifts. Different fonts have different ascent (height above baseline), descent (depth below baseline), and line gap (extra spacing) values—even when they appear the same size.
Calculating the Overrides
To eliminate layout shift completely, you need to match these three specific metrics. Here's the process:
- Measure your web font's metrics using browser DevTools or font analysis tools (ascent, descent, line-gap values)
- Measure your fallback font's metrics the same way
- Calculate override percentages to make the fallback match the web font
- Apply them in your CSS using the properties you've already learned
Applying the CSS
@font-face {
font-family: 'Fallback Arial';
src: local('Arial');
size-adjust: 107%; /* Overall size matching */
ascent-override: 90%; /* Adjust height above baseline */
descent-override: 25%; /* Adjust depth below baseline */
line-gap-override: 0%; /* Adjust extra line spacing */
}
body {
font-family: 'My Web Font', 'Fallback Arial', Arial, sans-serif;
}
These percentages are calculated from the ratio of your web font's metrics to your fallback's metrics, ensuring they occupy identical vertical space.
Key Takeaway: By calculating and setting ascent-override, descent-override, and line-gap-override based on the actual measured differences between your web font and fallback font, you achieve pixel-perfect matching that eliminates layout shift entirely.