Skip to content

fix(forms): use real font refs in appearance streams#21

Merged
Mythie merged 1 commit intomainfrom
fix/issue-18-flatten-embedded-fonts
Feb 8, 2026
Merged

fix(forms): use real font refs in appearance streams#21
Mythie merged 1 commit intomainfrom
fix/issue-18-flatten-embedded-fonts

Conversation

@Mythie
Copy link
Contributor

@Mythie Mythie commented Feb 8, 2026

Summary

Fixes #18 — form flatten with embedded fonts produces empty/incorrect output.

  • Appearance stream generators were creating incomplete stub font dictionaries (only Type/Subtype/BaseFont/Encoding) instead of referencing the complete Type0 font objects built at save time. After flattening, PDF viewers couldn't render glyph IDs because DescendantFonts, ToUnicode, and FontDescriptor were missing.
  • EmbeddedFont now stores its pre-allocated PdfRef (set by PDFFonts.embed()), and appearance builders reference it directly instead of creating stubs. This ensures flattened fields use the same complete font objects as non-flattened output.
  • Adds regression test with DejaVu Sans and Slovak diacritics (Ján Novák, Žilina, čšťňľ áéíóú) verifying that flattened PDFs contain complete Type0 font structures with DescendantFonts and ToUnicode entries.

Appearance stream generators were creating incomplete stub font
dictionaries (Type/Subtype/BaseFont/Encoding only) instead of
referencing the complete Type0 font objects built at save time.
After flattening, PDF viewers couldn't render the glyph IDs because
DescendantFonts, ToUnicode, and FontDescriptor were missing.

EmbeddedFont now stores its pre-allocated PdfRef (set by PDFFonts.embed),
and appearance builders reference it directly instead of creating stubs.
@vercel
Copy link
Contributor

vercel bot commented Feb 8, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
core Ready Ready Preview, Comment Feb 8, 2026 7:48am

@Mythie Mythie merged commit d27b372 into main Feb 8, 2026
5 checks passed
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.

Form flatten with embedded fonts produces empty/incorrect output

1 participant