| import { registerFont } from "canvas"; |
|
|
| let loaded = false; |
|
|
| |
| |
| const FONT_DIR = process.env.CAPTION_FONT_DIR || "/usr/share/fonts/truetype/reel"; |
|
|
| const FONTS = [ |
| { file: `${FONT_DIR}/Anton-Regular.ttf`, family: "Anton" }, |
| { file: `${FONT_DIR}/Oswald.ttf`, family: "Oswald" }, |
| ]; |
|
|
| export function loadFonts() { |
| if (loaded) return; |
| loaded = true; |
|
|
| for (const font of FONTS) { |
| try { |
| registerFont(font.file, { family: font.family }); |
| } catch (error) { |
| |
| console.error(`Failed to register font ${font.family} from ${font.file}:`, error); |
| } |
| } |
| } |
|
|