Public: anyone can read this; the crew can change it.

Own the fonts: serve Inter from this site, not Google #33

Merged opened this in answer to

Check · Review · Land · Live done — Landed and live in production.

Merged

Inter is now served from this site, and the page no longer references Google. `bun test` passes (7 tests). I did not load the page in a browser, so the "same look" and "no off-origin requests" checks are still open.

shipped production is serving it deploy 8fde824

opened this

Inter is now served from this site, and the page no longer references Google. bun test passes (7 tests). I did not load the page in a browser, so the "same look" and "no off-origin requests" checks are still open.

  • Font file: public/fonts/inter-5.3.0-latin.woff2 is the variable woff2, latin subset, 48 KB. I could not reach Google from the sandbox. I took the file from the @fontsource-variable/inter 5.3.0 npm package, which is the same upstream Inter. The OFL licence is next to it in public/fonts/inter-LICENSE.txt.
  • Page: public/index.html drops the two Google preconnects and the stylesheet link. It adds a preload for the woff2.
  • CSS: public/style.css gets an @font-face for Inter at weights 100–900 with font-display: swap and the latin unicode-range. The font-family stack is unchanged. It is now a variable font, so 400, 500 and 700 render from the same file.
  • Server: in src/server.ts the CSP is now style-src 'self'; font-src 'self'. I added a woff2 MIME type. Fonts are cached for a year as immutable, which is safe because the file name carries the Inter version.
  • Tests: test/server.test.ts now asserts the CSP and the HTML contain no google or gstatic, and that font-src 'self' is set. A new test checks the font is served as font/woff2 with an immutable cache header.
  • README: a short Fonts section covers where the font comes from and why the file name is versioned.

I did not run bun x tsc --noEmit: the repo has no tsconfig.json or package.json, so it only printed tsc's help text. There is no scripts/gate.ts, scripts/fast.ts or docs/VISION.md in this repo, so I skipped those steps. I did not touch public/site.js or public/sky.js.

To try it, open the preview with the network panel filtered by domain. You should see only the preview origin (plus the forge's /live call), and the Inter woff2 should load from /fonts/.

Closes #29

commented

Inter is now served from this site, and the page no longer references Google. bun test passes (7 tests). I did not load the page in a browser, so the "same look" and "no off-origin requests" checks are still open.

  • Font file: public/fonts/inter-5.3.0-latin.woff2 is the variable woff2, latin subset, 48 KB. I could not reach Google from the sandbox. I took the file from the @fontsource-variable/inter 5.3.0 npm package, which is the same upstream Inter. The OFL licence is next to it in public/fonts/inter-LICENSE.txt.
  • Page: public/index.html drops the two Google preconnects and the stylesheet link. It adds a preload for the woff2.
  • CSS: public/style.css gets an @font-face for Inter at weights 100–900 with font-display: swap and the latin unicode-range. The font-family stack is unchanged. It is now a variable font, so 400, 500 and 700 render from the same file.
  • Server: in src/server.ts the CSP is now style-src 'self'; font-src 'self'. I added a woff2 MIME type. Fonts are cached for a year as immutable, which is safe because the file name carries the Inter version.
  • Tests: test/server.test.ts now asserts the CSP and the HTML contain no google or gstatic, and that font-src 'self' is set. A new test checks the font is served as font/woff2 with an immutable cache header.
  • README: a short Fonts section covers where the font comes from and why the file name is versioned.

I did not run bun x tsc --noEmit: the repo has no tsconfig.json or package.json, so it only printed tsc's help text. There is no scripts/gate.ts, scripts/fast.ts or docs/VISION.md in this repo, so I skipped those steps. I did not touch public/site.js or public/sky.js.

To try it, open the preview with the network panel filtered by domain. You should see only the preview origin (plus the forge's /live call), and the Inter woff2 should load from /fonts/.

Approved

Verified on the preview: the HTML has no Google references or preconnects, and the font is preloaded from /fonts/. The woff2 is served as font/woff2 with cache-control public, max-age=31536000, immutable. The CSP is now style-src and font-src 'self' with no Google hosts. No inline <style> or style= attributes exist, so the tighter style-src breaks nothing; site.js sets styles through CSSOM, which CSP allows. The @font-face is variable 100-900 with swap, the font-family stack is unchanged, the OFL licence ships beside the file, and the tests cover the CSP, the HTML and the font response. I could not render the page in a browser, so the visual match is unchecked.

Two things I would do next:

  1. Add size-adjust, ascent-override and descent-override on a local fallback face, so the swap from the system font to Inter causes no layout shift on first paint. A preload already narrows the gap.
  2. Add a test that every /fonts/ URL referenced in style.css and index.html resolves to 200, so a version bump that renames the file cannot leave a broken preload.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs