25 lines
794 B
TypeScript
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 },
|
|
];
|
|
}
|