Repository navigation
fonts: ship real 600-weight subsets, and stop shipping each font twice - #3
Merged
Merged
Conversation
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
-400and-600of each family were byte-identical: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: 600whose file carries no 600instance 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
wghtdropsgvar,HVARand the rest of the variation machinery, so two real weights per familycost well under half of one duplicated variable font:
IBMPlexSans-400IBMPlexSans-600GeistMono-400GeistMono-600Shipping 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.shand asserts ingateway/introspection_test.go. Four filenames in, four filenames out: thisneeds 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 at600 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:
usWeightClass400/600,fvargone, and theBoutline coordinates genuinely differ (stems start 11 units further out at600).
Repeatability
fonts-src/keeps the variable sources, outsidepublic/so they are notbundled.
scripts/subset-fonts.pyregenerates the four files. Not wired intopnpm build— it needs a Python toolchain the repo does not otherwise have,to produce output that changes roughly never.
silently.
🤖 Generated with Claude Code