tools: Schriften plattformunabhängig finden, Setup für macOS dokumentieren
- tools/fontpicker.py sucht DejaVu über WESTREICHE_FONT_DIR, Linux-Pfade und ~/Library/Fonts statt festem /usr/share/fonts/truetype/dejavu - PDF-Skripte (Almanach, Liturgie, SL-Tabellen, SL-Schirm) nutzen den Finder - tools/requirements.txt (reportlab, markdown, pillow) + Setup-Abschnitt in AGENTS.md inkl. ghostscript, pandoc und font-dejavu für macOS
This commit is contained in:
parent
2dd6295caf
commit
7ab88b6d73
6 changed files with 91 additions and 3 deletions
15
AGENTS.md
15
AGENTS.md
|
|
@ -91,6 +91,21 @@ Wichtige Einstiege: `RPG/2-Spieler/` (je ein Ordner pro Spieler),
|
|||
|
||||
## Tooling
|
||||
|
||||
**Setup (einmalig, gilt für Linux und macOS):**
|
||||
|
||||
```bash
|
||||
python3 -m venv .venv
|
||||
.venv/bin/pip install -r tools/requirements.txt # reportlab, markdown, pillow
|
||||
```
|
||||
|
||||
Systemwerkzeuge: `ghostscript` (A4-Skalierung in den PDF-Builds), `pandoc`
|
||||
(ODT-Konvertierung), DejaVu-Schriften. Auf macOS per Homebrew:
|
||||
`brew install ghostscript pandoc && brew install --cask font-dejavu`. Die
|
||||
Schriften suchen die Skripte über `tools/fontpicker.py` (Linux-Pfade,
|
||||
`~/Library/Fonts`, Override `WESTREICHE_FONT_DIR`). Alle PDF-Skripte und
|
||||
`build_site.py` mit `.venv/bin/python` starten – das System-Python bringt weder
|
||||
`reportlab` noch `markdown` mit.
|
||||
|
||||
- `tools/md2odt.sh`, `tools/make_reference_odt.py`, `tools/autowidth.lua`:
|
||||
Markdown → ODT-Konvertierung für Druckmaterial.
|
||||
- `tools/build_zauber_almanach.py`: erzeugt das PDF-Handout
|
||||
|
|
|
|||
|
|
@ -53,7 +53,9 @@ PREP = VAULT / "7-Prep" / "prep_2026-11-20"
|
|||
QUELLE = PREP / "SL Schirm" / "SL-Schirm Inhalt.md"
|
||||
ZIEL = PREP / "SL Schirm" / "SL-Schirm (A5 quer).pdf"
|
||||
|
||||
FONT_DIR = Path("/usr/share/fonts/truetype/dejavu")
|
||||
from fontpicker import font_dir # noqa: E402
|
||||
|
||||
FONT_DIR = font_dir()
|
||||
pdfmetrics.registerFont(TTFont("Serif", str(FONT_DIR / "DejaVuSerif.ttf")))
|
||||
pdfmetrics.registerFont(TTFont("Serif-Bold", str(FONT_DIR / "DejaVuSerif-Bold.ttf")))
|
||||
pdfmetrics.registerFont(TTFont("Sans", str(FONT_DIR / "DejaVuSans.ttf")))
|
||||
|
|
|
|||
|
|
@ -35,7 +35,9 @@ VAULT = ROOT / "RPG"
|
|||
PREP = VAULT / "7-Prep" / "prep_2026-11-20"
|
||||
SRC_ARKAN = VAULT / "3-Welt" / "Geheimnisse" / "Es gibt kein unbegrenztes Zaubern.md"
|
||||
SRC_Klerus = VAULT / "5-Regeln" / "Hausregeln" / "Liturgien und Glaubensgemeinschaften.md"
|
||||
FONT_DIR = Path("/usr/share/fonts/truetype/dejavu")
|
||||
from fontpicker import font_dir # noqa: E402
|
||||
|
||||
FONT_DIR = font_dir()
|
||||
|
||||
pdfmetrics.registerFont(TTFont("Serif", str(FONT_DIR / "DejaVuSerif.ttf")))
|
||||
pdfmetrics.registerFont(TTFont("Serif-Bold", str(FONT_DIR / "DejaVuSerif-Bold.ttf")))
|
||||
|
|
|
|||
|
|
@ -41,7 +41,9 @@ VAULT = ROOT / "RPG"
|
|||
PREP = VAULT / "7-Prep" / "prep_2026-11-20"
|
||||
SPELL_DIR = VAULT / "5-Regeln" / "Zauber" / "Arkan"
|
||||
TITLE_IMAGE = PREP / "summarium_titelband.png"
|
||||
FONT_DIR = Path("/usr/share/fonts/truetype/dejavu")
|
||||
from fontpicker import font_dir # noqa: E402
|
||||
|
||||
FONT_DIR = font_dir()
|
||||
|
||||
# ---------------------------------------------------------------- Schriften
|
||||
pdfmetrics.registerFont(TTFont("Serif", str(FONT_DIR / "DejaVuSerif.ttf")))
|
||||
|
|
|
|||
55
tools/fontpicker.py
Normal file
55
tools/fontpicker.py
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
"""Findet das Verzeichnis mit den DejaVu-Schriften – Linux (Desktop) wie macOS.
|
||||
|
||||
Reihenfolge:
|
||||
1. Umgebungsvariable ``WESTREICHE_FONT_DIR`` (manueller Override),
|
||||
2. übliche Installationspfade (Linux-Distributionen, Homebrew-Cask auf macOS),
|
||||
3. Rückfall: Suche per ``fc-list``/``mdfind``-freier Kandidatenliste im Home-Verzeichnis.
|
||||
|
||||
Die PDF-Skripte registrieren ihre Schriften damit unabhängig vom Betriebssystem.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
CANDIDATES = (
|
||||
"/usr/share/fonts/truetype/dejavu", # Debian/Ubuntu
|
||||
"/usr/share/fonts/dejavu", # Fedora/Arch
|
||||
"/usr/share/fonts/TTF", # Arch
|
||||
"/usr/local/share/fonts/dejavu",
|
||||
"/opt/homebrew/share/fonts", # Homebrew (macOS, arm64)
|
||||
"/usr/local/share/fonts", # Homebrew (macOS, intel)
|
||||
"~/Library/Fonts", # macOS: `brew install --cask font-dejavu`
|
||||
"/Library/Fonts",
|
||||
"/System/Library/Fonts/Supplemental",
|
||||
)
|
||||
|
||||
NEEDED = ("DejaVuSerif.ttf", "DejaVuSans.ttf")
|
||||
|
||||
HINT = (
|
||||
"DejaVu-Schriften nicht gefunden. Installation:\n"
|
||||
" macOS: brew install --cask font-dejavu\n"
|
||||
" Debian: sudo apt install fonts-dejavu\n"
|
||||
" oder: WESTREICHE_FONT_DIR=/pfad/zu/den/ttf exportieren"
|
||||
)
|
||||
|
||||
|
||||
def _enough(path: Path) -> bool:
|
||||
return all((path / name).is_file() for name in NEEDED)
|
||||
|
||||
|
||||
def font_dir() -> Path:
|
||||
env = os.environ.get("WESTREICHE_FONT_DIR")
|
||||
if env:
|
||||
candidate = Path(env).expanduser()
|
||||
if _enough(candidate):
|
||||
return candidate
|
||||
raise SystemExit(f"WESTREICHE_FONT_DIR={env} enthält keine DejaVu-Schriften.\n{HINT}")
|
||||
|
||||
for raw in CANDIDATES:
|
||||
candidate = Path(raw).expanduser()
|
||||
if _enough(candidate):
|
||||
return candidate
|
||||
|
||||
raise SystemExit(HINT)
|
||||
12
tools/requirements.txt
Normal file
12
tools/requirements.txt
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# Python-Abhängigkeiten der Vault-Werkzeuge
|
||||
# Installation (Repo-Wurzel):
|
||||
# python3 -m venv .venv
|
||||
# .venv/bin/pip install -r tools/requirements.txt
|
||||
#
|
||||
# Systemwerkzeuge zusätzlich:
|
||||
# ghostscript (macOS: brew install ghostscript) – A4-Skalierung in den PDF-Builds
|
||||
# pandoc (macOS: brew install pandoc) – tools/md2odt.sh, tools/make_reference_odt.py
|
||||
# DejaVu-Fonts (macOS: brew install --cask font-dejavu) – alle reportlab-Builds
|
||||
reportlab>=4.0
|
||||
markdown>=3.4
|
||||
pillow>=10.0
|
||||
Loading…
Add table
Add a link
Reference in a new issue