init
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import { GlobalFonts } from "@napi-rs/canvas";
|
||||
import path from "node:path";
|
||||
import { PRESET_FONTS } from "./fonts";
|
||||
|
||||
let registered = false;
|
||||
|
||||
export function registerPresetFonts(): void {
|
||||
if (registered) return;
|
||||
|
||||
const dir = path.join(process.cwd(), "public", "fonts");
|
||||
for (const font of PRESET_FONTS) {
|
||||
GlobalFonts.registerFromPath(path.join(dir, font.regular), font.id);
|
||||
GlobalFonts.registerFromPath(path.join(dir, font.bold), font.id);
|
||||
}
|
||||
registered = true;
|
||||
}
|
||||
Reference in New Issue
Block a user