1- import { renderToSvg , renderToPng } from "@json-render/image/render" ;
1+ import { renderToPng } from "@json-render/image/render" ;
22import { examples } from "@/lib/examples" ;
33import type { Spec } from "@json-render/core" ;
44import { readFile } from "node:fs/promises" ;
5- import { join } from "node:path" ;
5+ import { createRequire } from "node:module" ;
6+
7+ const require = createRequire ( import . meta. url ) ;
68
79let fontCache : ArrayBuffer | null = null ;
810
911async function loadFont ( ) : Promise < ArrayBuffer > {
1012 if ( fontCache ) return fontCache ;
11- const buffer = await readFile (
12- join ( process . cwd ( ) , "public" , "Inter- Regular.ttf") ,
13- ) ;
13+ const fontPath =
14+ require . resolve ( "geist/dist/fonts/geist-sans/Geist- Regular.ttf") ;
15+ const buffer = await readFile ( fontPath ) ;
1416 fontCache = buffer . buffer . slice (
1517 buffer . byteOffset ,
1618 buffer . byteOffset + buffer . byteLength ,
@@ -49,7 +51,7 @@ async function imageResponse(spec: Spec, name: string, download: boolean) {
4951 const fontData = await loadFont ( ) ;
5052 const fonts = [
5153 {
52- name : "Inter " ,
54+ name : "Geist Sans " ,
5355 data : fontData ,
5456 weight : 400 as const ,
5557 style : "normal" as const ,
@@ -62,7 +64,7 @@ async function imageResponse(spec: Spec, name: string, download: boolean) {
6264 ? `attachment; filename="${ name } .png"`
6365 : `inline; filename="${ name } .png"` ;
6466
65- return new Response ( png as unknown as ArrayBuffer , {
67+ return new Response ( Buffer . from ( png ) , {
6668 headers : {
6769 "Content-Type" : "image/png" ,
6870 "Content-Disposition" : disposition ,
0 commit comments