AstroPaper uses Astro's fonts API. To replace the default 'Google Sans Code' font with a custom font, you must update the configuration in three specific files: astro.config.ts, src/layouts/Layout.astro, and src/styles/theme.css.
Important: Ensure the font name matches exactly as it appears on Google Fonts. For local fonts or other providers, follow the standard Astro Fonts documentation.
// 1. Update astro.config.ts
import { defineConfig, fontProviders } from "astro/config";
export default defineConfig({
// ...
fonts: [
{
name: "Your Font Name",
cssVariable: "--font-your-font",
provider: fontProviders.google(),
fallbacks: ["monospace"],
weights: [300, 400, 500, 600, 700],
styles: ["normal", "italic"],
},
],
});
// 2. Update src/layouts/Layout.astro
import { Font } from "astro:assets";
<head>
<Font
cssVariable="--font-your-font"
preload={[{ subset: "latin", weight: 400, style: "normal" }]}
/>
</head>
// 3. Update src/styles/theme.css
@theme inline {
--font-app: var(--font-your-font);
}