Engineering Guides

Zero Layout Shift Web Fonts: Calculating size-adjust & ascent-override

Eliminate Cumulative Layout Shift (CLS) on web font swap using exact OS/2 vs hhea formulas for size-adjust, ascent-override, and descent-override.

4 min readUpdated:

Quick Answer

Prevent Cumulative Layout Shift (CLS) during web font swap by pairing font-display: swap with a metric-aligned fallback @font-face declaration. Compute exact size-adjust, ascent-override, descent-override, and line-gap-override percentages from the font's OS/2 USE_TYPO_METRICS bit or hhea vertical metrics, scaled against letter-frequency weighted advance widths.

Why web fonts trigger Core Web Vitals CLS penalties

With font-display: swap, browsers paint text immediately using Arial, Times New Roman, or PingFang SC while the WOFF2 downloads. When the webfont arrives, two geometric mismatches cause visible page jumps: wider or narrower character advance widths alter line wrapping, and taller ascenders/descenders change paragraph height.

CSS Fonts Level 4 lets you reshape the local fallback font's glyph box metrics before the webfont even finishes downloading—making the fallback occupy the exact pixel footprint of your final webfont.

The exact OS/2 vs. hhea metric formulas

Naive scripts blindly read font.ascender and OS/2.xAvgCharWidth, which breaks on many fonts. Per OpenType rules, if bit 7 (0x0080, USE_TYPO_METRICS) of OS/2.fsSelection is set, browsers use sTypoAscender, sTypoDescender, and sTypoLineGap; otherwise they fall back to hhea.ascender, hhea.descender, and hhea.lineGap.

Furthermore, Latin fonts should compute average character width from English letter frequency against Arial (904/2048 em) or Times New Roman (819/2048 em), whereas CJK fonts use full-width 1.0 em square alignment against PingFang SC or Microsoft YaHei.

@font-face {
  font-family: 'Inter Fallback';
  src: local('Arial');
  size-adjust: 106.42%;
  ascent-override: 90.85%;
  descent-override: 22.64%;
  line-gap-override: 0.00%;
}

Verify visually with the Interactive Ghost Overlay

Open FontTo's Font CLS Generator and drop your .woff2 or .ttf file. Toggle the Ghost Overlay between OFF and ON to watch the translucent Arial/System fallback snap directly onto your webfont's baseline and right edge before copying the CSS.

Frequently asked questions

Does size-adjust work in Chrome, Safari, and Firefox?

Yes. size-adjust, ascent-override, descent-override, and line-gap-override are supported across Chrome, Edge, Safari 15.4+, and Firefox.

Why does FontTo distinguish Latin vs. CJK fallback presets?

CJK ideographs sit in a ~1.0 em full-width box, whereas Arial's average Latin width is ~0.44 em. Applying Latin ratios to a CJK font produces huge wrong scaling.

Should I still preload my primary font when using CLS overrides?

Yes. Preloading speeds up the swap while CLS metric overrides ensure zero layout jump even on slow mobile 3G connections.

Authoritative References

Tools used in this guide

Related formats

Related Comparisons

More engineering guides