Files
kickkingsadmin/src/lib/card-gen/font-files.ts
T
2026-09-14 13:23:14 +00:00

25 lines
794 B
TypeScript

import path from "node:path";
import { CUSTOM_FONT_FAMILY } from "@/lib/card-gen/id-config";
import { PRESET_FONTS } from "@/lib/card-gen/fonts";
export function fontsDir(): string {
return path.join(process.cwd(), "public", "fonts");
}
export function fontEntriesForFamily(
family: string,
customFontPath?: string | null,
): { path: string; family: string }[] {
if (family === CUSTOM_FONT_FAMILY) {
if (!customFontPath) return [];
return [{ path: customFontPath, family: CUSTOM_FONT_FAMILY }];
}
const preset = PRESET_FONTS.find((f) => f.family === family);
if (!preset) return [];
const dir = fontsDir();
return [
{ path: path.join(dir, preset.regularFile), family: preset.family },
{ path: path.join(dir, preset.boldFile), family: preset.family },
];
}