FE-M0-16 · Fonts through next/font, with no request to Google
ID FE-M0-16 · Level L0 · Run order row 28, after FE-M0-14 is merged · Why the Lighthouse audit, D8
Inter Tight and JetBrains Mono are hosted by the app itself, through next/font, and a page opening makes no request to fonts.googleapis.com or fonts.gstatic.com. Line 1 of design/opleet/opleet.css imports Google Fonts as a CSS @import, which holds up the page until two other origins have answered. The copy stays byte for byte as the design system published it (D8); postcss.config.mjs drops that one @import when the CSS is built, and app/layout.tsx loads both fonts. Committed on the branch web/fonts and merged.
Before
Section titled “Before”- FE-M0-14 is Done and pack D is merged: this step's app/layout.tsx and app/app.css are pack D's with the fonts added, and block 2 checks that first.
- fe-pack-d.zip is unzipped in ~/opleet-v2/packs (FE-M0-12 block 1). FE-M0-16's folder is in it.
- The Mac is online: the first build downloads the two fonts from Google once, and from then on serves them itself. Vercel is online at build time too.
- You are in ~/opleet-v2/opleet and git status --short prints nothing.
1 · A branch for the fonts
Section titled “1 · A branch for the fonts”git switch main && git pullgit switch -c web/fonts2 · Check the four files this step replaces, then copy them: layout.tsx, app.css, postcss.config.mjs and the note in design/opleet/SOURCE.md
Section titled “2 · Check the four files this step replaces, then copy them: layout.tsx, app.css, postcss.config.mjs and the note in design/opleet/SOURCE.md”shasum -a 256 -c ~/opleet-v2/packs/fe-pack-d/FE-M0-16/BASE.sha256 && cp -R ~/opleet-v2/packs/fe-pack-d/FE-M0-16/apps . && git status --short3 · Typecheck, lint and build
Section titled “3 · Typecheck, lint and build”pnpm --filter web typecheckpnpm lintpnpm --filter web build4 · Start the app, open the sign-in page with the browser's Network tab open, and filter it by “font”. Then stop the app with Ctrl+C
Section titled “4 · Start the app, open the sign-in page with the browser's Network tab open, and filter it by “font”. Then stop the app with Ctrl+C”pnpm --filter web dev5 · Commit, push, open the pull request, merge
Section titled “5 · Commit, push, open the pull request, merge”git add -A apps/webgit commit -m "feat(web): host the fonts with next/font (d8)"git push -u origin web/fontsgh pr create --title "feat(web): host the fonts with next/font" --body "FE-M0-16: no request to Google Fonts; opleet.css unchanged (D8)."gh pr checks --watchgh pr merge --squash --delete-branchgit switch maingit pullExpect
Section titled “Expect”- Block 2: four lines ending in “: OK”, then M for apps/web/app/app.css, apps/web/app/layout.tsx, apps/web/design/opleet/SOURCE.md and apps/web/postcss.config.mjs, and nothing else.
- Block 3: typecheck prints “design/opleet/tokens.css and theme.css are up to date”, the Keys line and no errors; “No fixes applied.”; the build lists the same routes as FE-M0-10 and does not fail on a font.
- Block 4: two font files, both from localhost:3000/_next/static/media, with a name ending in .woff2; no request to fonts.googleapis.com or fonts.gstatic.com. The sign-in page looks the same as before.
- Block 5: checks and pr-title pass, then “✓ Squashed and merged pull request #…”.
Run it after block 3, before block 5.
grep -rlE 'fonts\.(googleapis|gstatic)\.com' apps/web/.next/static apps/web/.next/serverls apps/web/.next/static/media | grep -c '\.woff2$'(cd apps/web && shasum -a 256 -c design/opleet/SHA256SUMS | grep -vc ': OK$')Expect: the first prints nothing; the second prints 2; the third prints 0, so every file in design/opleet still matches its checksum.
Then run the Lighthouse audit again, on the Vercel preview of the pull request or on pnpm --filter web build and pnpm --filter web start, and log the score on #18. The fonts should no longer appear among the render-blocking requests, and the waterfall has no third-party origin for them. If a score moved, say which one.
If it fails
Section titled “If it fails”- Block 2 prints “FAILED” for a file and stops: your copy of that file is not pack D's (main has changed it, or it was edited by hand). Nothing was copied. Paste the FAILED lines and stop; FE rebuilds the step.
- The build says “Failed to fetch
Inter Tightfrom Google Fonts”: this machine could not reach Google while building. Check the connection and run block 3 again. Paste the line if it repeats. - A request to fonts.googleapis.com is still there: the first command of the Check lists the file that holds it. If that is a .css file in .next,
postcss.config.mjsdid not run: pastecat apps/web/postcss.config.mjs. - The text shows in the system font: open the Elements tab, select
<html>, and look at its class and at the computed--font-sans. The class should hold the two names from next/font, and--font-sansshould start withvar(--font-inter-tight). Paste both. - A shift of the text as the font arrives: expected for a moment.
display: swapshows the text at once, and next/font gives the fallback font Inter Tight's metrics so the lines don't move.
git checkout -- apps/webgit switch maingit branch -D web/fontsBefore the commit. After it, before merging: gh pr close --delete-branch. After merging: revert it with a new pull request.
Not run yet.