Self-host fonts (drop Google Fonts CDN)#14
Merged
Conversation
Bundle the webfonts in the RCL instead of loading them from fonts.googleapis.com so the app works offline, has no third-party network dependency, and gets consistent first-paint metrics (no CDN fallback-advance window). - Added woff2 files (latin subset, SIL OFL) under SharpClient.UI/wwwroot/fonts/ and @font-face declarations in SharpClient.UI/wwwroot/fonts.css: JetBrains Mono 400/700, IBM Plex Mono 400/700, Space Mono 400/700, Space Grotesk 400/500/600. - Both hosts (Web App.razor, App index.html) now link _content/SharpClient.UI/fonts.css and the Google Fonts <link>/preconnects are removed. - Bonus: IBM Plex Mono and Space Mono are selectable output fonts but the old Google links never actually loaded them (only JetBrains Mono + Space Grotesk), so those options silently fell back to system mono. They now work. Verified in the Web preview: JetBrains Mono + Space Grotesk load from _content/.../fonts/, IBM Plex/Space Mono resolve on demand, zero requests to googleapis/gstatic. All 9 woff2 bundle into the Android APK assets. ~146 KB total. Web + Android build clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HHCRc5CJ6595iMzEgYYdQp
There was a problem hiding this comment.
Pull request overview
This PR moves the app’s typography off Google Fonts by introducing self-hosted WOFF2 font assets in SharpClient.UI and updating both the web host and app host to load a shared fonts.css from _content/SharpClient.UI, improving offline support and removing third‑party network dependencies.
Changes:
- Removed Google Fonts
<link>+ preconnects from both hosts. - Added
src/SharpClient.UI/wwwroot/fonts.csswith@font-facedeclarations for the bundled fonts. - Introduced local WOFF2 font files under
src/SharpClient.UI/wwwroot/fonts/to back the new@font-facerules.
Reviewed changes
Copilot reviewed 3 out of 12 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/SharpClient.Web/Components/App.razor | Swaps Google Fonts includes for the shared _content/SharpClient.UI/fonts.css stylesheet. |
| src/SharpClient.UI/wwwroot/fonts.css | Adds @font-face rules for self-hosted mono/UI fonts and points to bundled WOFF2 assets. |
| src/SharpClient.App/wwwroot/index.html | Swaps Google Fonts includes for the shared _content/SharpClient.UI/fonts.css stylesheet. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1
to
+6
| /* Self-hosted fonts (SIL Open Font License) — no external CDN, works offline. | ||
| woff2 files live alongside this file under _content/SharpClient.UI/fonts/; the url()s are relative | ||
| to this stylesheet. Latin subset only (Fontsource) — non-latin glyphs fall back to the system | ||
| monospace/sans in the --mono/--ui stacks. Weights match what the UI uses: mono 400/700 (bold ANSI), | ||
| Space Grotesk 400/500/600 (UI chrome). font-display:swap so text paints immediately with the | ||
| fallback and re-lays out when the webfont loads. */ |
Comment on lines
+3
to
+6
| to this stylesheet. Latin subset only (Fontsource) — non-latin glyphs fall back to the system | ||
| monospace/sans in the --mono/--ui stacks. Weights match what the UI uses: mono 400/700 (bold ANSI), | ||
| Space Grotesk 400/500/600 (UI chrome). font-display:swap so text paints immediately with the | ||
| fallback and re-lays out when the webfont loads. */ |
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.
Bundle the webfonts in the app instead of loading them from
fonts.googleapis.com.Why
What
SharpClient.UI/wwwroot/fonts/with@font-facedeclarations inSharpClient.UI/wwwroot/fonts.css: JetBrains Mono 400/700, IBM Plex Mono 400/700, Space Mono 400/700, Space Grotesk 400/500/600. (~146 KB total.)SharpClient.Web/Components/App.razor,SharpClient.App/wwwroot/index.html) now link_content/SharpClient.UI/fonts.css; the Google Fonts<link>+ preconnects are removed.Bonus fix
IBM Plex Mono and Space Mono are offered as output-font options in Settings, but the old Google
<link>only loaded JetBrains Mono + Space Grotesk — so picking those two silently fell back to system mono. They now render for real.Verification
_content/.../fonts/; IBM Plex/Space Mono resolve on demand; zero requests to googleapis/gstatic.obj/.../assets/wwwroot/_content/SharpClient.UI/fonts/).🤖 Generated with Claude Code