"""Font resolution helpers for PDF rendering.""" from __future__ import annotations from dataclasses import dataclass from pathlib import Path @dataclass(frozen=True) class QuartoFonts: main_font: str sans_font: str requires_system_fonts: bool def resolve_quarto_fonts(fonts_dir: Path) -> QuartoFonts: """Resolve Quarto font names. Quarto/xelatex currently uses installed font family names. We still accept fonts_dir so callers can validate/report environment state consistently. """ expected = [ fonts_dir / "SourceHanSerifSC-Regular.otf", fonts_dir / "SourceHanSansSC-Bold.otf", ] requires_system_fonts = not all(path.exists() for path in expected) return QuartoFonts( main_font="Source Han Serif CN", sans_font="Source Han Sans CN", requires_system_fonts=requires_system_fonts, )