"""동봉 폰트 로더. 없으면 그 자리에서 죽는다 — 기본 폰트로 떨어지면 타이포가 어긋난다.""" from functools import lru_cache from pathlib import Path from PIL import ImageFont FONT_DIR = Path(__file__).resolve().parent.parent / "assets" / "fonts" PRETENDARD = "Pretendard-{weight}.otf" GYEONGGI = "GyeonggiTitleVOTF-Bold.otf" @lru_cache(maxsize=32) def font(weight: str, size: int) -> ImageFont.FreeTypeFont: path = FONT_DIR / PRETENDARD.format(weight=weight) if not path.exists(): raise RuntimeError(f"폰트 없음: {path}") return ImageFont.truetype(str(path), size) @lru_cache(maxsize=8) def title_font(size: int) -> ImageFont.FreeTypeFont: path = FONT_DIR / GYEONGGI if not path.exists(): raise RuntimeError(f"폰트 없음: {path}") return ImageFont.truetype(str(path), size)