Skip to content

Fix subset font rendering in both Acrobat and Illustrator#117

Open
diaconu-andrei wants to merge 5 commits intoprawnpdf:masterfrom
diaconu-andrei:fix-both-acrobat-illustrator
Open

Fix subset font rendering in both Acrobat and Illustrator#117
diaconu-andrei wants to merge 5 commits intoprawnpdf:masterfrom
diaconu-andrei:fix-both-acrobat-illustrator

Conversation

@diaconu-andrei
Copy link

This PR fixes subset font compatibility issues that caused corrupted text rendering in Adobe Illustrator while keeping Acrobat working correctly

Changes:

  • cmap table: Added a Mac Roman (platform 1, encoding 0) subtable alongside the existing Windows Unicode subtable. Illustrator needs this to resolve glyph IDs back to characters when editing embedded font text (without it, it falls back to treating glyph IDs as raw character codes, producing garbled output)
  • name table: The PostScript name tag is now generated as 6 uppercase letters per PDF spec §5.5.3 (digits map to A–J, hex letters map to K–P). More importantly, the subset now mirrors the platform records the original font already has for the PostScript name (name ID 6) instead of always writing a Mac Roman record. Illustrator requires a Windows UTF-16BE (platform 3) record; blindly adding a platform 1 record to fonts that never had one caused Illustrator to misread the subset and render corrupted text.
  • Test: Updated the expected name table checksum to reflect the new Windows UTF-16BE PostScript name record.

According to PDF spec section 5.5.3, font subset tags must be 6 uppercase
letters. This converts the hex digest (0-9a-f) to uppercase letters:
- Digits 0-9 map to letters A-J
- Hex a-f map to letters K-P

This maintains 1-to-1 deterministic mapping while satisfying the PDF spec
requirement for 6 uppercase letters. Fixes both Adobe Acrobat (issue prawnpdf#102)
and Adobe Illustrator warnings.

Fixes: prawnpdf#102
Related: prawnpdf#107
Made-with: Cursor
@55728
Copy link

55728 commented Mar 25, 2026

Thanks for opening this @diaconu-andrei!
Looking forward to seeing this merged alongside #116 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants