Loheide-eu-mitarbeiterplatt.../scripts/generate-fonts-css.py
Friederich Loheide 82bbeef31b
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 2m7s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 2m11s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 2m16s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 2m18s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 2m49s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 2m46s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 2m41s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 2m33s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m0s
Phase 5: Erscheinungsbild mit Entwurf, Vorschau und Veröffentlichen
- Theme in den Einstellungen (Entwurf/veröffentlicht), Übernahme der
  Einstellungen aus Phase 0; statische CSS-Datei mit Hash beim Veröffentlichen
- Logos hell/dunkel, Signet, App-Symbol → Favicon, Homescreen-Symbole,
  Web-App-Manifest; SVG-Bereinigung
- Markenfarbe exakt, zweite Akzentfarbe, Kopfleiste hell/Marke/dunkel,
  Kontrastprüfung (WCAG AA) mit automatisch lesbarer Linkfarbe
- Lokale Schriften (Latein), Überschriften-Schrift, eigene WOFF2-Schrift,
  Ecken, Dichte, Dunkelmodus-Regel
- Anmeldeseite (geteilt/zentriert, Bild, Texte), Fußzeile, E-Mails im Design
- Admin: Live-Vorschau (Startseite, Anmeldung, Beispielseite; hell/dunkel),
  Veröffentlichen, Verwerfen, Export/Import, Zurücksetzen, eigenes CSS
- Admin-Bereich übernimmt Logo, Farbe und Favicon; Whitelabel

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-26 10:46:05 +00:00

53 lines
2.5 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
"""
Erzeugt resources/css/fonts.css: die mitgelieferten Schriften (lokal, nie von
Google Fonts) – nur die Zeichensätze Latein und Latein-Erweitert, damit der
mitversionierte Build klein bleibt. Aufruf nach dem Hinzufügen einer Schrift:
python3 scripts/generate-fonts-css.py
Die Liste muss zu App\\Support\\Theme\\Fonts passen.
"""
import re, pathlib
ROOT = pathlib.Path(__file__).resolve().parent.parent
FONTS = [
# (Paket, CSS-Datei, Familienname im Portal)
('@fontsource-variable/inter', 'wght.css', 'Inter Variable'),
('@fontsource-variable/source-sans-3', 'wght.css', 'Source Sans 3 Variable'),
('@fontsource-variable/open-sans', 'wght.css', 'Open Sans Variable'),
('@fontsource-variable/nunito-sans', 'wght.css', 'Nunito Sans Variable'),
('@fontsource-variable/roboto', 'wght.css', 'Roboto Variable'),
('@fontsource-variable/ibm-plex-sans', 'wght.css', 'IBM Plex Sans Variable'),
('@fontsource-variable/figtree', 'wght.css', 'Figtree Variable'),
('@fontsource/atkinson-hyperlegible', '400.css', 'Atkinson Hyperlegible'),
('@fontsource/atkinson-hyperlegible', '700.css', 'Atkinson Hyperlegible'),
('@fontsource-variable/source-serif-4', 'wght.css', 'Source Serif 4 Variable'),
('@fontsource-variable/merriweather', 'wght.css', 'Merriweather Variable'),
('@fontsource-variable/lora', 'wght.css', 'Lora Variable'),
]
out = ['/* Automatisch erzeugt von scripts/generate-fonts-css.py – nicht von Hand ändern. */']
for package, css, family in FONTS:
base = ROOT / 'node_modules' / package
text = (base / css).read_text()
blocks = re.findall(r'/\* ([^*]+) \*/\s*(@font-face\s*\{[^}]*\})', text)
kept = 0
for name, block in blocks:
if not re.search(r'-latin(-ext)?-', name + '-'):
continue
if 'latin' not in name:
continue
subset = re.search(r'-(latin-ext|latin)-', name)
if not subset:
continue
block = re.sub(r"font-family:\s*'[^']+'", f"font-family: '{family}'", block)
# Pfade relativ zu resources/css/fonts.css
block = re.sub(r'url\(\./files/', f'url(../../node_modules/{package}/files/', block)
block = re.sub(r',\s*url\([^)]*\.woff\)\s*format\([^)]*\)', '', block)
out.append(f'/* {name} */\n{block}')
kept += 1
if kept == 0:
raise SystemExit(f'Keine lateinischen Schnitte gefunden: {package}/{css}')
(ROOT / 'resources/css/fonts.css').write_text('\n'.join(out) + '\n')
print('fonts.css geschrieben')