Failed to create opengraph image
Unanswered
Trigg Hound posted this in #help-forum
Trigg HoundOP
import { ImageResponse } from 'next/og'
// Route segment config
export const runtime = 'edge'
// Image metadata
export const alt = 'text'
export const size = {
width: 1200,
height: 630,
}
export const contentType = 'image/png'
// Image generation
export default async function Image() {
// Font
const wted = fetch(
new URL('./WantedSans-ExtraBlack.otf', import.meta.url)
).then((res) => res.arrayBuffer())
return new ImageResponse(
(
// ImageResponse JSX element
<div
style={{
fontFamily: 'Wanted Sans ExtraBlack',
fontSize: 128,
fontWeight: '900',
background: 'black',
color: 'white',
width: '100%',
height: '100%',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
text
</div>
),
// ImageResponse options
{
// For convenience, we can re-use the exported opengraph-image
// size config to also set the ImageResponse's width and height.
...size,
fonts: [
{
name: 'Wanted Sans ExtraBlack',
data: await wted,
},
],
}
)
}
I can't get my og image. [Font](https://github.com/wanteddev/wanted-sans)
4 Replies
Trigg HoundOP
any help?
Sphecid wasp
What's the base you're using for the URL?
Trigg HoundOP
It seems like next's font handling has some issue, but i can't find any workarounds
[cause]: Error: lookupType: 6 - substFormat: 1 is not yet supported