Using line-gap-override for Precision
What you'll learn: How to use line-gap-override to fine-tune the internal spacing within font lines and eliminate the last remaining vertical spacing mismatches between web fonts and their fallback fonts.
What Is Line Gap?
In typography, the line gap (also called "internal leading") is extra vertical space built into the font file itself, distributed above and below each line of text. Different fonts include different amounts of line gap, which can cause noticeable shifts when a web font loads and replaces its fallback.
Why You Need line-gap-override
You've already adjusted ascent-override and descent-override to match the upper and lower extents of your fonts. But if the web font and fallback have different line gaps, you'll still see subtle layout shifts. The text block's total height might change by a few pixels—enough to trigger Cumulative Layout Shift (CLS) issues.
How It Works
The line-gap-override property lets you override the fallback font's built-in line gap to match your web font's line gap:
@font-face {
font-family: 'Fallback Arial';
src: local('Arial');
ascent-override: 90%;
descent-override: 22%;
line-gap-override: 0%;
}
Setting line-gap-override: 0% forces the fallback to have no internal line gap, matching web fonts that typically have minimal line gaps. If your web font does have a line gap, you'd set the percentage to match.
The Complete Picture
Think of it like adjusting a picture frame: ascent and descent control the top and bottom borders, while line gap controls the internal matting. All three must match for a perfect fit.
Key Takeaway: line-gap-override eliminates the final piece of vertical spacing mismatch by overriding the fallback font's internal leading, ensuring pixel-perfect alignment when your web font loads.