From 1220e5ad6c73e73e578e989dc244062be26088fb Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sun, 1 Nov 2026 09:04:49 -1000 Subject: [PATCH 1/4] fonts: embed core fonts and add metric-matched fallbacks to stop layout shift Fonts were loaded from fontsource's CSS with font-display: swap, so text was laid out in a system fallback first and reflowed when each font arrived. - Declare all @font-face rules in src/lib/fonts/fonts.css, loaded as its own stylesheet so its hash only changes when the fonts do. - Inline the five latin files every page uses (Inter 400/600/700, JetBrains Mono 400, Monument Extended Black) as data URIs via assetsInlineLimit, so they arrive with render-blocking CSS. Other subsets stay as regular files. - Add metric-matched local fallbacks (Arial, Arial Bold, Courier New, Arial Black) with size-adjust/ascent/descent overrides computed from the font files, so the brief pre-decode fallback takes the same space. - Use --font-sans/--font-mono/--font-display variables for every font-family declaration. Co-Authored-By: Claude Opus 5.5 --- src/app.css | 9 +- src/lib/components/Badge.svelte | 2 +- src/lib/components/HeaderBanner.svelte | 2 +- src/lib/components/NoteCard.svelte | 2 +- src/lib/components/Product.svelte | 2 +- .../ProductDescriptions/CommaFour.svelte | 2 +- src/lib/components/ReleaseNote.svelte | 2 +- src/lib/components/TestimonialCards.svelte | 4 +- src/lib/components/TestimonialSection.svelte | 2 +- .../components/VariantRadioSelector.svelte | 2 +- src/lib/fonts/fonts.css | 346 ++++++++++++++++++ src/routes/+layout.svelte | 27 +- src/routes/connect/+page.svelte | 4 +- src/routes/jobs/+page.svelte | 10 +- src/routes/openpilot/+page.svelte | 6 +- src/routes/setup/+page.svelte | 4 +- src/routes/shop/body/+page.svelte | 2 +- src/routes/shop/chestnut/+page.svelte | 6 +- src/routes/shop/comma-four/+page.svelte | 4 +- src/routes/vehicles/+page.svelte | 2 +- vite.config.js | 2 + 21 files changed, 389 insertions(+), 53 deletions(-) create mode 100644 src/lib/fonts/fonts.css diff --git a/src/app.css b/src/app.css index 2597137e..3f9f0495 100644 --- a/src/app.css +++ b/src/app.css @@ -19,7 +19,7 @@ body { body { color: #000; - font-family: Inter, sans-serif; + font-family: var(--font-sans); font-size: 16px; font-weight: 400; line-height: 1.4; @@ -68,6 +68,11 @@ body { --color-card-background: #f8f9fa; --color-card-background-hover: #e8eaec; + /* each web font is followed by a metric-matched fallback from src/lib/fonts/fonts.css */ + --font-sans: Inter, 'Inter Fallback', sans-serif; + --font-mono: 'JetBrains Mono', 'JetBrains Mono Fallback', monospace; + --font-display: 'Monument Extended Black', 'Monument Extended Black Fallback', sans-serif; + h1, h2, h3, @@ -244,7 +249,7 @@ hr { button, select { color: #000; - font-family: Inter, sans-serif; + font-family: var(--font-sans); } .mobile-first { diff --git a/src/lib/components/Badge.svelte b/src/lib/components/Badge.svelte index d31a68a9..f15079c0 100644 --- a/src/lib/components/Badge.svelte +++ b/src/lib/components/Badge.svelte @@ -15,7 +15,7 @@