Skip to content

Embed handwriting fonts in the exported PDF#50

Merged
ankitsejwal merged 3 commits into
mainfrom
feat/pdf-fonts
Jun 28, 2026
Merged

Embed handwriting fonts in the exported PDF#50
ankitsejwal merged 3 commits into
mainfrom
feat/pdf-fonts

Conversation

@ankitsejwal

Copy link
Copy Markdown
Member

Closes #23.

The PDF used Helvetica while the preview showed handwriting — so the export never matched the screen. Now the selected caption font is embedded in the PDF, making it WYSIWYG.

How

  • Bundled static TTFs for the caption fonts under src/fonts/, imported as ?url assets and fetched lazily at export time (cached), then embedded subsetted via @pdf-lib/fontkit.
  • The handwriting font is used for captions, dates, and the camera line — matching the on-screen sheet exactly. Falls back to Helvetica if a font can't load.
  • Added ttf to the PWA precache so export stays fully offline.

Why Caveat was dropped
The blocker on #23 was never variable-vs-static — I rendered a static Caveat instance and it still came out "Cort ona". Caveat is a semi-connected script that relies on GPOS kerning, which pdf-lib doesn't apply, so letters drift apart. Rather than ship a font that can't print faithfully, I replaced Caveat with Indie Flower — a casual handwriting font that's unconnected and renders pixel-perfect. The set is now Indie Flower (default) · Patrick Hand · Shadows Into Light · Kalam, all WYSIWYG.

Verification
Rendered a sample PDF per font (pdf-lib + fontkit) and rasterized to PNG to eyeball spacing: Indie Flower, Patrick Hand, Shadows Into Light and Kalam all render "Cortona / October 2008 / Nikon D7000 35mm" correctly (Caveat was the only one that broke). Embedding works with subset: true. typecheck / oxlint / build green; all 4 TTFs land in the SW precache.

If you'd rather keep Caveat on screen, I can add it back as a screen-only font, or implement manual GPOS kerning for it in the PDF — say the word.

@ankitsejwal ankitsejwal merged commit 8ecb2be into main Jun 28, 2026
1 check passed
@ankitsejwal ankitsejwal deleted the feat/pdf-fonts branch June 28, 2026 15:37
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.

Embed selected handwriting font in exported PDF

1 participant