Skip to content

feat: add fonts: asset key to bring fonts into the deck contract#160

Merged
mizzy merged 1 commit into
mainfrom
issue-159-fonts-asset
Jul 7, 2026
Merged

feat: add fonts: asset key to bring fonts into the deck contract#160
mizzy merged 1 commit into
mainfrom
issue-159-fonts-asset

Conversation

@mizzy

@mizzy mizzy commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add fonts: frontmatter key (with deck-adjacent fonts/ auto-detect) as a first-class asset, parallel to layouts:/css:/syntaxes:.
  • Copy the resolved fonts verbatim into build output, PDF workspace, and present cache so site / PDF / presenter all render with the same fonts regardless of host.
  • Fixes the WenQuanYi Zen Hei + DejaVu Sans fallback on Linux CI that was breaking site-vs-PDF parity in decks.gosu.ke.
  • Design record: docs/plans/2026-07-07-fonts-asset.md.

Closes #159.

Highlights

  • No CSS url() parsing. Deck CSS writes url("fonts/xxx.woff2"); the emitted peitho.css sits at the output root so the relative URL resolves to the copied fonts/ sibling.
  • Both file and directory input, matching the sibling asset keys' shape. Nested subdirs (e.g. @fontsource/inter/) are supported.
  • Watch-mode aware: recursive watch-tree expansion for fonts subdirs (notify is non-recursive), dotfile filtering to avoid .DS_Store/.swp rebuild storms.
  • Publish-safe: dist/fonts/ is always cleared at build time so a removed fonts: key doesn't leak stale bytes into peitho publish.
  • Symlinks rejected symmetrically for source and inner entries — silent dropping is forbidden by CLAUDE.md.
  • After this ships, the decks repo can migrate build.mjs's font injection to fonts: (documented in the plan doc; not in this PR).

Test plan

  • cargo test --workspace (3× per race-check discipline) — 490 passing
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo fmt --all --check
  • git diff --exit-code bindings/
  • cd packages/peitho-present && npm run build && npm test && npm run typecheck
  • git diff --exit-code packages/peitho-present/dist/shell.js
  • Manual smoke on a real deck: point fonts: at a Noto Sans JP .woff2 + @font-face CSS, run peitho export pdf, verify /BaseFont shows Noto (not WenQuanYi) in the exported PDF

🤖 Generated with Claude Code

https://claude.ai/code/session_01M2CDJTHJnfgNJrDJTamnQC

Closes #159.

Adds a fonts: frontmatter key (with deck-adjacent fonts/ auto-detect)
that resolves to a directory or file. peitho then copies the fonts
verbatim into the build output, the PDF export workspace, and the
present cache — so site, PDF, and presenter all render with the same
web fonts regardless of host environment (fixes WenQuanYi Zen Hei
fallback on Linux CI).

The five-lens invariants held: symlinks rejected symmetrically for
source and directory entries, deterministic filename order, dotfile
filtering in watch mode, always-clear dist/fonts/ so a removed fonts:
key doesn't leak stale bytes into publish, and recursive watch
expansion for nested subdirs like @fontsource/inter/.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M2CDJTHJnfgNJrDJTamnQC
@mizzy mizzy merged commit dea439a into main Jul 7, 2026
4 checks passed
@mizzy mizzy mentioned this pull request Jul 7, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PDF export: サイトと同じウェブフォントで組めず、環境のフォールバックフォントでメトリクスと字形が変わる

1 participant