code / legex /pdf_export /font_keys.py
anonymous
[code] Reproduction bundle.
2e511b5
Raw History Blame Contribute Delete
1.08 kB
"""Map workbook location / stem label to body-text font preset."""
from __future__ import annotations
from pathlib import Path
# data/<cc>/… — two-letter folder names from legex scrapers
FONT_BY_CC: dict[str, str] = {
"kr": "han_k",
"in": "deva",
"np": "deva", # Nepali — Devanagari script
"am": "arm",
"ge": "geo",
"tw": "han_tc", # Traditional Chinese (Source Han Sans TC, also covers Latin)
"hk": "han_tc", # mostly English judgments, occasional Chinese names
"cn": "han_sc", # Simplified Chinese
}
# Goldenset_* stem label (ohne Präfix), z. B. aus älteren Drive-Layouts
FOLDER_FONT_BY_STEM: dict[str, str] = {
"China": "han_sc",
"South_Korea": "han_k",
"Taiwan": "han_tc",
"Hong_Kong": "han_tc",
"India": "deva",
"Armenia": "arm",
"Georgia": "geo",
}
def font_key_for_workbook(xlsx: Path) -> str:
cc = xlsx.parent.name
if cc in FONT_BY_CC:
return FONT_BY_CC[cc]
stem_label = xlsx.stem.removeprefix("Goldenset_")
return FOLDER_FONT_BY_STEM.get(stem_label, "default")