fix(web): self-host Inter and JetBrains Mono fonts - #753
Merged
Conversation
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>
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.
What
Self-host Inter and JetBrains Mono instead of loading them from
fonts.googleapis.comat runtime.Why
web/index.htmlpulled both families from Google Fonts via a render-blocking<link>. On networks wherefonts.googleapis.com/fonts.gstatic.comare 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
@fontsourcedistribution) underweb/public/fonts/— Inter 400/500/600/700 and JetBrains Mono 400/500, each split intolatin+latin-ext.web/public/fonts/fonts.csswith@font-facerules using the standardlatin/latin-extunicode-rangesplits (browser only fetches the subset a glyph needs) andfont-display: swap.index.html: replaced the twopreconnecthints and the Google Fonts<link>with<link rel="stylesheet" href="/fonts/fonts.css" />, and droppedhttps://fonts.googleapis.com(style-src) andhttps://fonts.gstatic.com(font-src) from the page's meta CSP.Notes / scope
web/src/index.cssalso namesSyne/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.skillhub-auth/.../SecurityConfig.javauntouched to avoid conflicting with fix(security): harden CSP policy and hide nginx server tokens #748, which is already tightening that block; its now-unusedfonts.googleapis.com/fonts.gstatic.comallowances are harmless but could be dropped there too once fix(security): harden CSP policy and hide nginx server tokens #748 lands.Closes #716