Skip to content

fix(web): self-host Inter and JetBrains Mono fonts - #753

Merged
XiaoSeS merged 2 commits into
mainfrom
feat/self-host-google-fonts
Aug 25, 2026
Merged

fix(web): self-host Inter and JetBrains Mono fonts#753
XiaoSeS merged 2 commits into
mainfrom
feat/self-host-google-fonts

Conversation

@FenjuFu

@FenjuFu FenjuFu commented Aug 24, 2026

Copy link
Copy Markdown
Member

What

Self-host Inter and JetBrains Mono instead of loading them from fonts.googleapis.com at runtime.

Why

web/index.html pulled both families from Google Fonts via a render-blocking <link>. On networks where fonts.googleapis.com / fonts.gstatic.com are slow or unreachable (notably CN), that stylesheet blocks first paint — #716 measured ~70s. It's also an external dependency and a third-party origin in the CSP for no functional gain.

How

  • Vendored the same woff2 Google serves (from the @fontsource distribution) under web/public/fonts/ — Inter 400/500/600/700 and JetBrains Mono 400/500, each split into latin + latin-ext.
  • Added web/public/fonts/fonts.css with @font-face rules using the standard latin / latin-ext unicode-range splits (browser only fetches the subset a glyph needs) and font-display: swap.
  • index.html: replaced the two preconnect hints and the Google Fonts <link> with <link rel="stylesheet" href="/fonts/fonts.css" />, and dropped https://fonts.googleapis.com (style-src) and https://fonts.gstatic.com (font-src) from the page's meta CSP.

Notes / scope

  • Only Inter and JetBrains Mono were ever fetched from the CDN, so families, weights and rendering are unchanged; after this change there are no external font requests.
  • web/src/index.css also names Syne / IBM Plex Sans (line 95) but those were never in the Google Fonts link, so they already fell back to system fonts — out of scope here.
  • I left the CSP header in skillhub-auth/.../SecurityConfig.java untouched to avoid conflicting with fix(security): harden CSP policy and hide nginx server tokens #748, which is already tightening that block; its now-unused fonts.googleapis.com / fonts.gstatic.com allowances are harmless but could be dropped there too once fix(security): harden CSP policy and hide nginx server tokens #748 lands.
  • Total added assets ~320 KB across 12 woff2 files.

Closes #716

FenjuFu and others added 2 commits August 25, 2026 01:31
web/index.html loaded Inter + JetBrains Mono from fonts.googleapis.com at
runtime. On networks where Google Fonts is slow or unreachable (e.g. CN),
that stylesheet blocks first paint for tens of seconds (#716).

Vendor the same woff2 (from the @fontsource distribution) under
web/public/fonts and declare them in fonts.css with latin/latin-ext
unicode-range splits and font-display: swap, then point index.html at the
local stylesheet and drop the fonts.googleapis.com / fonts.gstatic.com hosts
from the page CSP. Only Inter and JetBrains Mono were ever fetched from the
CDN, so families and weights are unchanged; no external font requests remain.

Closes #716

Signed-off-by: FenjuFu <92919259+FenjuFu@users.noreply.github.com>
Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
@XiaoSeS
XiaoSeS merged commit 1c3e9be into main Aug 25, 2026
10 checks 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.

[Feature] 自托管 Google Fonts 消除外部 CDN 依赖

2 participants