From d81f4ab2f13527491511d421847414725ccdc9dc Mon Sep 17 00:00:00 2001 From: yuanzonghao Date: Sun, 24 May 2026 15:20:15 +0800 Subject: [PATCH] refactor(web): self-host fonts via next/font/google Replace external to fonts.googleapis.com with next/font/google for Cormorant Garamond and Inter. Fonts are now built-time downloaded and served from /_next/static/media, exposed via --font-serif and --font-sans CSS variables that Tailwind's fontFamily reads. Eliminates runtime dependency on Google Fonts CDN (helpful for offline or region-restricted deploys), avoids FOUT through next/font's size-adjusted fallback, and removes two render-blocking external stylesheet requests on first load. Co-Authored-By: Claude Opus 4.7 (1M context) --- apps/web/app/layout.tsx | 32 +++++++++++++++++++++----------- apps/web/tailwind.config.ts | 4 ++-- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/apps/web/app/layout.tsx b/apps/web/app/layout.tsx index 48a1308..9bb1cdc 100644 --- a/apps/web/app/layout.tsx +++ b/apps/web/app/layout.tsx @@ -1,6 +1,22 @@ import type { Metadata } from "next"; +import { Cormorant_Garamond, Inter } from "next/font/google"; import "./globals.css"; +const cormorant = Cormorant_Garamond({ + subsets: ["latin"], + weight: ["300", "400", "500", "600"], + style: ["normal", "italic"], + variable: "--font-serif", + display: "swap", +}); + +const inter = Inter({ + subsets: ["latin"], + weight: ["300", "400", "500"], + variable: "--font-sans", + display: "swap", +}); + export const metadata: Metadata = { title: "云梦 — AI 视觉小说", description: "一部由 AI 实时绘制每一帧的开源视觉小说。", @@ -12,18 +28,12 @@ export default function RootLayout({ children: React.ReactNode; }) { return ( - + - - -