Skip to content

Self-host fonts (drop Google Fonts CDN)#14

Merged
HarryCordewener merged 1 commit into
masterfrom
feat/self-host-fonts
Jul 1, 2026
Merged

Self-host fonts (drop Google Fonts CDN)#14
HarryCordewener merged 1 commit into
masterfrom
feat/self-host-fonts

Conversation

@HarryCordewener

Copy link
Copy Markdown
Member

Bundle the webfonts in the app instead of loading them from fonts.googleapis.com.

Why

  • Works offline / no third-party network dependency.
  • Consistent first-paint metrics (no CDN fallback-advance window that the column-fit math had to cope with).
  • Fixes two font options that never actually loaded (see below).

What

  • Added woff2 files (latin subset, SIL OFL) under SharpClient.UI/wwwroot/fonts/ with @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. (~146 KB total.)
  • Both hosts (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

  • 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 (obj/.../assets/wwwroot/_content/SharpClient.UI/fonts/).
  • Web + Android build clean.

🤖 Generated with Claude Code

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
Copilot AI review requested due to automatic review settings July 1, 2026 02:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.css with @font-face declarations for the bundled fonts.
  • Introduced local WOFF2 font files under src/SharpClient.UI/wwwroot/fonts/ to back the new @font-face rules.

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. */
@HarryCordewener
HarryCordewener merged commit c33fb7d into master Jul 1, 2026
3 checks passed
@HarryCordewener
HarryCordewener deleted the feat/self-host-fonts branch July 1, 2026 02:51
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.

2 participants