Variable font in vercel og
Unanswered
Abyssinian posted this in #help-forum
AbyssinianOP
How to load a variable font such as
I am trying to load is like this:
but getting this error:
Geist[wght].ttf in vervel og?I am trying to load is like this:
fonts: [
{
name: 'Geist',
data: await fetch(
new URL(`${origin}/GeistMono[wght].ttf`)
).then(res => res.arrayBuffer()),
weight: 800, // Base weight
style: 'normal',
}
]but getting this error:
Error: failed to pipe response
at ignore-listed frames {
[cause]: TypeError: Cannot read properties of undefined (reading '256')
at ignore-listed frames
}
GET /api/og?username=meow 500 in 70ms (compile: 1714µs, render: 68ms)2 Replies
Western paper wasp
@vercel/og/Satori often can’t parse variable TTFs (like GeistMono[wght].ttf) — it expects a static font file. Export/download a static Geist/GeistMono (e.g. GeistMono-Regular.ttf / GeistMono-Bold.ttf) and use that in fonts.Also make sure the fetch actually succeeds:
const res = await fetch(new URL("/GeistMono-Bold.ttf", origin));
if (!res.ok) throw new Error('Font fetch failed: ${res.status}');
const data = await res.arrayBuffer();Vercel OG / Fonts
https://vercel.com/docs/functions/edge-functions/og-image-generation#fonts
Discussion of variable fonts
https://github.com/vercel/satori/issues/530