Course contentsShow
← Web Development
Lesson 1313 of 2,98223. Web Font OptimizationFree lesson

Size-Adjust for Fallback Font Matching

Use the size-adjust descriptor to scale fallback fonts to match custom font dimensions exactly.

Size-Adjust for Fallback Font Matching

You'll learn how to use the size-adjust descriptor to scale fallback fonts so they match your custom web font's dimensions perfectly.

The Problem This Solves

Imagine you've chosen a beautiful custom font for your website, but while it loads, the browser displays a fallback font (like Arial). If these fonts have different sizes at the same font-size setting, text will suddenly jump and resize when your custom font arrives. This causes layout shift and a jarring user experience.

What is size-adjust?

The size-adjust descriptor lets you scale a fallback font up or down to match the apparent size of your custom font. Think of it like adjusting the volume on two speakers so they sound equally loud—here, you're adjusting the "visual volume" of your fallback font.

You apply size-adjust inside an @font-face rule for your fallback font, not your custom font. The value is a percentage: 100% means no change, 90% shrinks the font, 110% enlarges it.

How It Works

/* Your custom web font */
@font-face {
  font-family: 'CustomFont';
  src: url('custom-font.woff2') format('woff2');
  font-display: swap;
}

/* Scaled fallback to match CustomFont */
@font-face {
  font-family: 'CustomFont-fallback';
  src: local('Arial');
  size-adjust: 95%;
  ascent-override: 100%;
  descent-override: 20%;
}

body {
  font-family: 'CustomFont', 'CustomFont-fallback', sans-serif;
}

In this example, Arial is scaled down to 95% of its normal size to match CustomFont's dimensions better, reducing layout shift when the custom font loads.

Key Takeaway: Use size-adjust in a fallback @font-face rule to scale system fonts, minimizing layout shift during web font loading by matching the visual size of your custom font.