Nuxt OG Image uses @nuxt/fonts for font management. This is required for custom fonts.
@nuxt/fonts:npx nuxi module add @nuxt/fonts
nuxt.config.ts with global: true:export default defineNuxtConfig({
modules: ['@nuxt/fonts', 'nuxt-og-image'],
fonts: {
families: [
{ name: 'Inter', weights: [400, 700], global: true },
],
},
})
global: true option is required for fonts to be available in OG Image rendering. Without it, fonts won't be loaded.<template>
<div style="font-family: 'Inter'">
<h1>{{ title }}</h1>
</div>
</template>
Use any provider supported by @nuxt/fonts:
export default defineNuxtConfig({
fonts: {
families: [
// Google Fonts (default provider)
{ name: 'Roboto', weights: [400, 700], global: true },
// Explicit provider
{ name: 'Inter', provider: 'bunny', weights: [400, 700], global: true },
// Local fonts (must be woff2 format)
{
name: 'MyFont',
src: '/fonts/MyFont.woff2',
weight: 400,
global: true,
},
],
},
})
Different renderers support different font formats:
| Format | Satori | Takumi | Chromium |
|---|---|---|---|
| woff2 | ❌ | ✅ | ✅ |
| woff | ✅ | ✅ | ✅ |
| ttf | ✅ | ✅ | ✅ |
| otf | ✅ | ✅ | ✅ |
global: true setfonts.familiesFor regions where Google Fonts is blocked, use local fonts or an alternative provider:
export default defineNuxtConfig({
fonts: {
providers: {
google: false,
},
families: [
{
name: 'Inter',
src: '/fonts/Inter-Regular.woff2',
weight: 400,
global: true,
},
],
}
})