Skip to content

fonts: ship real 600-weight subsets, and stop shipping each font twice - #3

Merged
blakebauman merged 1 commit into
mainfrom
fonts-real-weights
Aug 11, 2026
Merged

blakebauman merged 1 commit into
mainfrom
fonts-real-weights

Conversation

@blakebauman

Copy link
Copy Markdown
Member

The -400 and -600 of each family were byte-identical:

$ md5 public/fonts/*.woff2          # before
GeistMono-400-latin.woff2   = cd5b25781181c5c03d99ac2cbf88016a
GeistMono-600-latin.woff2   = cd5b25781181c5c03d99ac2cbf88016a
IBMPlexSans-400-latin.woff2 = d28498895ed7050c37c94ddd026a4670
IBMPlexSans-600-latin.woff2 = d28498895ed7050c37c94ddd026a4670

Both copies were the variable font — wght axis intact, IBM Plex Sans
100–700 and Geist Mono 100–900, defaulting to 400 — declared in CSS as two
static faces. A face declared font-weight: 600 whose file carries no 600
instance renders the outlines it has, so nothing on the page has ever
actually been bold
, and the payload was doubled to achieve that.

Nothing catches this by eye. The page renders; it just renders wrong.

The fix, and why not the obvious one

Instance the sources at each declared weight. Pinning wght drops gvar,
HVAR and the rest of the variation machinery, so two real weights per family
cost well under half of one duplicated variable font:

before after
IBMPlexSans-400 40,240 16,628
IBMPlexSans-600 40,240 18,556
GeistMono-400 23,108 9,880
GeistMono-600 23,108 10,180
fonts 126,696 55,244
bundle total 312,937 241,487

Shipping each variable font once under a weight range is the obvious
alternative and is wrong twice over. It is larger — 63 KB against 55 KB,
because variation deltas cost more than a second instanced outline set when
only two weights are used — and it changes the shipped file set, which fold
pins in scripts/sync-console.sh and asserts in
gateway/introspection_test.go. Four filenames in, four filenames out: this
needs no change on fold's side.

The budget goes back to 320 KiB

The number this repo used before the rewrite. The 71 KiB recovered here is more
than the framework cost, so the raise to 384 is retired rather than kept as
slack. Fonts were the larger half of the bundle; now they are under a quarter
of it.

Verification

In a browser, against the built bundle: all four faces report loaded, and at
600 IBM Plex Sans lays down 34% more ink and Geist Mono 20% more.

Ink coverage rather than text width, deliberately — a monospace face has the
same advance at every weight, so a width comparison would have "passed" on
Geist Mono while proving nothing. (It did, on the first attempt: 336.00 at both
weights.)

Font metadata also checks out: usWeightClass 400/600, fvar gone, and the
B outline coordinates genuinely differ (stems start 11 units further out at
600).

Repeatability

  • fonts-src/ keeps the variable sources, outside public/ so they are not
    bundled.
  • scripts/subset-fonts.py regenerates the four files. Not wired into
    pnpm build — it needs a Python toolchain the repo does not otherwise have,
    to produce output that changes roughly never.
  • CI asserts no two shipped font files are identical, so this cannot come back
    silently.

🤖 Generated with Claude Code

The -400 and -600 of each family were byte-identical. Both were the *variable*
font — wght axis intact, IBM Plex Sans 100-700 and Geist Mono 100-900,
defaulting to 400 — declared in CSS as two static faces. A face declared
`font-weight: 600` whose file carries no 600 instance renders the outlines it
has, so nothing on the page has ever actually been bold, and the payload was
doubled to achieve that. Nothing catches this by eye: the page renders, it just
renders wrong.

Instance the sources at each declared weight instead. Pinning wght drops gvar,
HVAR and the rest of the variation machinery, so two real weights per family
now cost well under half of one duplicated variable font:

  IBMPlexSans-400   40240 -> 16628      GeistMono-400   23108 ->  9880
  IBMPlexSans-600   40240 -> 18556      GeistMono-600   23108 -> 10180

  fonts   126696 -> 55244        bundle total   312937 -> 241487

Shipping each variable font once under a weight range was the obvious
alternative and is wrong twice over: it is larger (63 KB against 55 KB, since
variation deltas cost more than a second instanced outline set when only two
weights are used), and it changes the shipped file set, which fold pins in
scripts/sync-console.sh and asserts in gateway/introspection_test.go. Four
filenames in, four filenames out — this needs no change on fold's side.

The byte budget goes back to 320 KiB, the number it had before the rewrite. The
71 KiB recovered here is more than the framework cost, so the raise to 384 is
retired rather than kept as slack.

Verified in a browser against the built bundle: all four faces load, and at 600
IBM Plex Sans lays down 34% more ink and Geist Mono 20% more. Ink coverage
rather than text width, because a monospace face has the same advance at every
weight — width would have "passed" while proving nothing.

  - fonts-src/ keeps the variable sources, outside public/ so they are not
    bundled, so this is reproducible.
  - scripts/subset-fonts.py regenerates the four files. Not wired into
    `pnpm build`: it needs a Python toolchain the repo does not otherwise have,
    to produce output that changes roughly never.
  - CI asserts no two shipped font files are identical.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@blakebauman
blakebauman merged commit f1d5aad into main Aug 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant