Notifio self-hosts its fonts, not for privacy points but because next/font/google broke on an ampersand and the two woff2 files ended up committed to the repo. Since then I have written about what is inside them and which pages preload them.
What I had never looked at is the other half of the mechanism: the fallback. next/font writes a second @font-face for each family, pointing at a font already on your machine, with the metrics bent to match the one being downloaded. It is the thing that is supposed to make the swap free. This post measures whether it does.
Five font-face rules, three of them real
The site serves one stylesheet, 39,976 bytes, and this is every @font-face in it:
@font-face{font-family:GeistMono;src:url(...GeistMono_Variable...woff2);font-display:swap;font-weight:100 900} @font-face{font-family:spaceGrotesk;src:url(...space_grotesk_latin-s...woff2);font-display:swap;font-weight:300 700} @font-face{font-family:dmSans;src:url(...dm_sans_latin-s...woff2);font-display:swap;font-weight:300 700} @font-face{font-family:spaceGrotesk Fallback;src:local(Arial); ascent-override:88.78%;descent-override:26.34%;line-gap-override:0.0%;size-adjust:110.84%} @font-face{font-family:dmSans Fallback;src:local(Arial); ascent-override:94.36%;descent-override:29.49%;line-gap-override:0.0%;size-adjust:105.13%} Three downloads and two synthetic families made out of the reader's copy of Arial. The stacks they feed look like this:
--font-sans: dmSans, "dmSans Fallback", ui-sans-serif, system-ui, sans-serif; --font-mono: GeistMono, ui-monospace, SFMono-Regular, Roboto Mono, Menlo, ... , monospace; Note what the mono family does not have: a GeistMono Fallback. Two of our three typefaces get a metric-matched stand-in and the third goes straight to the system's monospace.
The experiment
Load all 38 URLs from the sitemap twice in the same Chromium, once normally and once with every .woff2 request aborted, and in each pass walk every text node and record the rect of its contents:
const ctx = await browser.newContext({ viewport: { width: 1280, height: 900 } }); if (blocked) await ctx.route("**/*.woff2", r => r.abort()); // ... per page: document.fonts.ready, then a TreeWalker over SHOW_TEXT, // Range.getClientRects() for each non-empty node Blocking the files is not a theoretical state. It is what a reader on a flaky connection gets for the first second or two, and what a reader behind a proxy that strips font requests gets forever.
Two passes over 4,207 text nodes:
| Measurement | Result |
|---|---|
| Text nodes measured | 4,207 |
| Nodes whose top moved by 0.5px or more | 1,280 (30.4%) |
| Summed text width, loaded | 950,027px |
| Summed absolute width difference | 19,669px (2.07%) |
Pages whose scrollHeight changed | 13 of 38 |
| Largest height change | /alerts/housinganywhere, 3,794px to 3,844px |
| Typical height change | 24 or 25px, which is one line of body text |
h1 size or position change | none on any page I sampled |
The headings not moving is the fallback working as designed, and for a reason the overrides have nothing to do with: our headings sit in fixed-width containers with an explicit line height, so the only thing a narrower or wider typeface can do inside them is change where the words break. The paragraphs are where the 2 per cent of width turns into one extra line, and one extra line is where a page gains 24 pixels.
Six descriptors that cannot fire
Each fallback rule carries four descriptors. Three of them, ascent-override, descent-override and line-gap-override, exist to make a line box the same height with the fallback as with the real font. So I counted the line heights on the site:
Elements with text, across 38 pages 7,478 with computed line-height: normal 0 Zero. body sets line-height: 1.6 and everything else uses a Tailwind leading-* class, so every line box on the site already has an explicit height in pixels. The ascent, descent and line-gap overrides can change nothing. Six of the eight descriptors in those two rules are inert on this site, and the one that does all the work is size-adjust.
That is not a complaint about next/font, which cannot know what our stylesheet does. It is the answer to "do we need the fallback rules at all", and the answer is yes, but only for one number out of four.
What size-adjust actually does to one sentence
Here is the same 56-character sentence rendered at 15px in every family involved, measured in the browser:
| Family | Width | Height at line-height: normal |
|---|---|---|
dmSans (what we download) | 390.70px | 20px |
dmSans Fallback (Arial at 105.13%) | 400.30px | 20px |
Arial (unadjusted) | 381.00px | 17px |
system-ui | 389.13px | 18px |
| the browser's default | 349.50px | 17px |
spaceGrotesk | 408.94px | 19px |
spaceGrotesk Fallback (Arial at 110.84%) | 422.14px | 19px |
GeistMono | 513.00px | 19px |
monospace | 513.09px | 17px |
Two things fall out of that table.
The override column is real: adjusted Arial matches dmSans at 20px against raw Arial's 17px, which is exactly what those three inert descriptors would be for on a site that used line-height: normal.
The width column is less flattering. size-adjust: 105.13% takes Arial from 381px to 400.30px, overshooting dmSans by 9.6px, while system-ui, the family sitting two entries further along the same stack, lands 1.57px away with no adjustment at all. That is one sentence and one machine, and size-adjust is a single scalar fitted to average advance widths across a whole charset rather than to this string, so it is not evidence the ratio is wrong. It is evidence that on macOS, for body copy, the stand-in we construct is slightly wider than the one the operating system would have offered.
And there is a reader for whom none of it applies. src: local(Arial) matches nothing on a machine without Arial, which is most Android and Linux devices. There, the synthetic family simply fails to load, the stack falls through, and the reader gets system-ui unadjusted.
What the swap costs in shift
Font metrics only matter if the fallback is ever painted. So, with CDP throttling at 1.6 Mbps and 150ms of latency, with a layout-shift observer installed before the first byte:
| Page | Fonts | FCP | Fonts complete | Shifts | CLS |
|---|---|---|---|---|---|
| /help | allowed | 916ms | 1,265 / 1,602 / 2,053ms | 1 at 1,614ms | 0.00244 |
| /help | blocked | 740ms | - | 0 | 0 |
| /alerts/housinganywhere | allowed | 948ms | 1,244 / 1,573 / 2,031ms | 1 at 1,584ms | 0.01212 |
| /alerts/housinganywhere | blocked | 712ms | - | 0 | 0 |
| /guides/rental-scams-netherlands | allowed | 948ms | 1,266 / 1,588 / 2,039ms | 1 at 1,602ms | 0.00005 |
| /guides/rental-scams-netherlands | blocked | 700ms | - | 0 | 0 |
Every page gets exactly one shift, it happens within 20ms of the body font arriving, and the worst of the three is 0.01212 against a "good" budget of 0.1. Blocking the fonts gives a perfect zero and a first paint around 200ms earlier, which is the trade stated as plainly as it can be: our typeface costs us 0.012 and a fifth of a second, and that is a price worth paying.
At the two ends of the connection range the swap stops existing in different directions. On a desk connection the three files finish between 246ms and 272ms against a first paint at 380ms, so the fallback is never painted. On slow 3G, first paint is at 2.9 seconds and the three fonts land at 4.6, 5.9 and 7.9 seconds, so there are three full seconds of Arial on screen before the page becomes itself.
The file that is last every time
The last column of that story is worth one more count. Across the 38 pages, of 7,478 text-bearing elements:
sans (dmSans) 7,088 mono (GeistMono) 354 display (spaceGrotesk) 36 And of the 130,668 bytes of font we ship, GeistMono is 71,368, more than the other two put together. It is the biggest file, it serves 354 elements out of 7,478, it is the only one of the three with no metric-matched fallback, and on every throttled profile I ran it arrives last: 2,053ms on fast 3G, 7,908ms on slow 3G. The 36 display elements, meanwhile, are the ones a reader looks at first.
Takeaways
- Check whether your fallback's overrides can do anything.
ascent-override,descent-overrideandline-gap-overrideonly change a line box whose height isnormal. If your stylesheet sets a line height everywhere,size-adjustis the only descriptor in play. - Measure a font swap by aborting the font requests, not by reading the CSS. Two passes over the same pages with
route("**/*.woff2", abort)gives you the shift in text nodes, page heights and CLS in one run. -
src: local(Arial)is a bet on the reader's machine. On Android and Linux the metric-matched family does not load and the whole adjustment is skipped, so the stack after it is what you are actually shipping. - A tiny CLS is still worth naming. 0.012 is not a problem, but knowing it is 0.012 and not 0.12 is the difference between a decision and a hope.
- The biggest font file is often the least used one. Count elements per family before you decide what to preload.
The pages measured here are live: the help page, the HousingAnywhere alerts page that gains the 50 pixels, the scams guide, and the download page for the app this website is in front of.
