Release v2.12.0: Implement single-layer compression enforcement, 256KB plan archive cap with git.libre.audio citations, cold-archived inactive plans, codebase modularity/security/economization (Strategies 1A/2B/3A/4A/5A/6A/7A), and /quant/ spoken voice narration & #lensSelect UI element indicators (Strategies 1B/2A/3A/4A)
This commit is contained in:
1 parent
cc73a57bd8
commit
a066a0d03d
69 files changed
+2334
-619
No files matched your search
@@ -1,11 +1,13 @@
|
||||
"""
|
||||
hyperstitionstud_io.publishing.fonts — Cross-OS TrueType Font Resolver with Built-In Fallbacks.
|
||||
hyperstitionstud_io.publishing.fonts — Cross-OS TrueType Font Resolver, `@lru_cache` Pillow Font Loader,
|
||||
and Shared Group 3 ("Stealth Basalt Plate & Micro-Pip Signal Ribbon") Pillow Drawing Primitives.
|
||||
Searches Debian/Ubuntu, Fedora/RHEL, Arch, Alpine, macOS, and user font directories so PDF and
|
||||
PNG rendering never crashes on OS-specific font paths.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import functools
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
@@ -13,6 +15,7 @@ FONT_SEARCH_DIRS = [
|
||||
Path("/usr/share/fonts/truetype/dejavu"),
|
||||
Path("/usr/share/fonts/dejavu-sans-fonts"),
|
||||
Path("/usr/share/fonts/dejavu-sans-mono-fonts"),
|
||||
Path("/usr/share/fonts/google-noto"),
|
||||
Path("/usr/share/fonts/TTF"),
|
||||
Path("/usr/share/fonts/dejavu"),
|
||||
Path.home() / ".local" / "share" / "fonts",
|
||||
@@ -21,6 +24,69 @@ FONT_SEARCH_DIRS = [
|
||||
Path("/System/Library/Fonts"),
|
||||
]
|
||||
|
||||
# Shared Group 3 Preferred Default Palette Tokens (90% Quiet Matte Basalt / 7% #38bdf8 Interactive / 3% Explicit Lock Beacons)
|
||||
GROUP3_PALETTE: dict[str, tuple[int, int, int]] = {
|
||||
"BG_VOID": (2, 6, 23), # #020617
|
||||
"BG_WELL": (7, 13, 27), # #070d1b
|
||||
"BG_ODD": (12, 19, 36), # #0c1324
|
||||
"BG_EVEN": (17, 26, 46), # #111a2e
|
||||
"BG_BEZEL": (24, 35, 56), # #182338
|
||||
"BORDER_MUTED": (38, 52, 77), # #26344d
|
||||
"TXT_PRI": (226, 232, 240), # #e2e8f0
|
||||
"TXT_SEC": (148, 163, 184), # #94a3b8
|
||||
"TXT_DIM": (100, 116, 139), # #64748b
|
||||
"CYAN": (56, 189, 248), # #38bdf8
|
||||
"GOLD": (245, 158, 11), # #f59e0b
|
||||
"EMERALD": (16, 185, 129), # #10b981
|
||||
"ROSE": (244, 63, 94), # #f43f5e
|
||||
"VIOLET": (168, 85, 247), # #a855f7
|
||||
}
|
||||
|
||||
|
||||
def chamfer_polygon_points(
|
||||
x0: int,
|
||||
y0: int,
|
||||
x1: int,
|
||||
y1: int,
|
||||
ctl: int = 10,
|
||||
ctr: int = 10,
|
||||
cbr: int = 4,
|
||||
cbl: int = 4,
|
||||
) -> list[tuple[int, int]]:
|
||||
return [
|
||||
(x0 + ctl, y0),
|
||||
(x1 - ctr, y0),
|
||||
(x1, y0 + ctr),
|
||||
(x1, y1 - cbr),
|
||||
(x1 - cbr, y1),
|
||||
(x0 + cbl, y1),
|
||||
(x0, y1 - cbl),
|
||||
(x0, y0 + ctl),
|
||||
]
|
||||
|
||||
|
||||
def draw_group3_chamfered_plate(
|
||||
draw: Any,
|
||||
box: tuple[int, int, int, int],
|
||||
fill: tuple[int, int, int],
|
||||
attention_color: tuple[int, int, int] | None = None,
|
||||
pip_color: tuple[int, int, int] | None = None,
|
||||
) -> None:
|
||||
x0, y0, x1, y1 = box
|
||||
out_col = attention_color if attention_color else GROUP3_PALETTE["BORDER_MUTED"]
|
||||
pts = chamfer_polygon_points(x0, y0, x1, y1, 10, 10, 4, 4)
|
||||
draw.polygon(pts, fill=fill, outline=out_col)
|
||||
band_h = min(y1 - y0, 26)
|
||||
for y in range(y0 + 3, y0 + band_h, 3):
|
||||
for x in range(x0 + 8 + (y % 2) * 3, x1 - 8, 6):
|
||||
draw.point((x, y), fill=(22, 33, 54))
|
||||
draw.polygon(
|
||||
[(x0 + 10, y0 + 1), (x1 - 10, y0 + 1), (x1 - 7, y0 + 4), (x0 + 7, y0 + 4)],
|
||||
fill=GROUP3_PALETTE["BG_BEZEL"],
|
||||
)
|
||||
pcol = attention_color or pip_color or (71, 85, 105)
|
||||
draw.rectangle((x0 + 14, y0 + 1, x0 + 48, y0 + 4), fill=pcol)
|
||||
|
||||
|
||||
def _reportlab_vera_fallback(filename: str) -> Path | None:
|
||||
try:
|
||||
@@ -43,7 +109,11 @@ def _reportlab_vera_fallback(filename: str) -> Path | None:
|
||||
return None
|
||||
|
||||
|
||||
@functools.lru_cache(maxsize=64)
|
||||
def resolve_font_path(filename: str, fallback_filename: str | None = None) -> Path | None:
|
||||
cand_direct = Path(filename)
|
||||
if cand_direct.is_absolute() and cand_direct.is_file():
|
||||
return cand_direct
|
||||
for d in FONT_SEARCH_DIRS:
|
||||
cand = d / filename
|
||||
if cand.is_file():
|
||||
@@ -65,6 +135,7 @@ def resolve_font_path(filename: str, fallback_filename: str | None = None) -> Pa
|
||||
return _reportlab_vera_fallback(filename)
|
||||
|
||||
|
||||
@functools.lru_cache(maxsize=64)
|
||||
def load_pillow_font(filename: str, size: int) -> Any:
|
||||
from PIL import ImageFont
|
||||
|
||||
|
||||
Reference in new issue
Block a user