feat(portability): add __file__-anchored WORKSPACE_ROOT discovery, cross-OS font resolver, and public HTTP onboarding quickstart (v1.2.0)

This commit is contained in:
Hermes Agent committed 2026-11-29 21:20:46 +00:00
1 parent f8235a2037
commit 4e38541fbf
7 files changed
+227 -103

No files matched your search

@@ -54,27 +54,37 @@ def compile_markdown_to_pdf(
Table,
TableStyle,
)
from hyperstitionstud_io.publishing.fonts import resolve_font_path
md_p = Path(md_path).resolve()
pdf_p = Path(pdf_path).resolve()
pdf_p.parent.mkdir(parents=True, exist_ok=True)
tmp_p = pdf_p.with_suffix(f".tmp.{os.getpid()}.pdf")
oblique_ttf = "/usr/share/fonts/truetype/dejavu/DejaVuSans-Oblique.ttf"
bold_oblique_ttf = "/usr/share/fonts/truetype/dejavu/DejaVuSans-BoldOblique.ttf"
pdfmetrics.registerFont(TTFont("DejaVu", "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"))
pdfmetrics.registerFont(TTFont("DejaVu-Bold", "/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf"))
pdfmetrics.registerFont(TTFont("DejaVu-Oblique", oblique_ttf if Path(oblique_ttf).is_file() else "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"))
pdfmetrics.registerFont(TTFont("DejaVu-BoldOblique", bold_oblique_ttf if Path(bold_oblique_ttf).is_file() else "/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf"))
pdfmetrics.registerFont(TTFont("DejaVuMono", "/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf"))
pdfmetrics.registerFont(TTFont("DejaVuMono-Bold", "/usr/share/fonts/truetype/dejavu/DejaVuSansMono-Bold.ttf"))
pdfmetrics.registerFontFamily(
"DejaVu",
normal="DejaVu",
bold="DejaVu-Bold",
italic="DejaVu-Oblique",
boldItalic="DejaVu-BoldOblique",
)
f_reg = resolve_font_path("DejaVuSans.ttf")
f_bold = resolve_font_path("DejaVuSans-Bold.ttf")
f_ob = resolve_font_path("DejaVuSans-Oblique.ttf", fallback_filename="DejaVuSans.ttf")
f_bob = resolve_font_path("DejaVuSans-BoldOblique.ttf", fallback_filename="DejaVuSans-Bold.ttf")
f_mreg = resolve_font_path("DejaVuSansMono.ttf")
f_mbold = resolve_font_path("DejaVuSansMono-Bold.ttf")
if f_reg and f_bold and f_mreg and f_mbold:
pdfmetrics.registerFont(TTFont("DejaVu", str(f_reg)))
pdfmetrics.registerFont(TTFont("DejaVu-Bold", str(f_bold)))
pdfmetrics.registerFont(TTFont("DejaVu-Oblique", str(f_ob or f_reg)))
pdfmetrics.registerFont(TTFont("DejaVu-BoldOblique", str(f_bob or f_bold)))
pdfmetrics.registerFont(TTFont("DejaVuMono", str(f_mreg)))
pdfmetrics.registerFont(TTFont("DejaVuMono-Bold", str(f_mbold)))
pdfmetrics.registerFontFamily(
"DejaVu",
normal="DejaVu",
bold="DejaVu-Bold",
italic="DejaVu-Oblique",
boldItalic="DejaVu-BoldOblique",
)
base_font, bold_font, mono_font = "DejaVu", "DejaVu-Bold", "DejaVuMono"
else:
base_font, bold_font, mono_font = "Helvetica", "Helvetica-Bold", "Courier"
styles = getSampleStyleSheet()
st_h1 = ParagraphStyle("HS_H1", parent=styles["Heading1"], fontName="DejaVu-Bold", fontSize=15, leading=19, textColor=colors.HexColor("#111827"), spaceAfter=8)