Skip to content

fix(font): bound SFNT output and encode names correctly - #1057

Merged
andiwand merged 3 commits into
mainfrom
review/39-sfnt-serialization
Oct 5, 2026
Merged

andiwand merged 3 commits into
mainfrom
review/39-sfnt-serialization

Conversation

@andiwand

@andiwand andiwand commented Oct 4, 2026 •

Copy link
Copy Markdown
Member

🤖 Generated with Claude Code

Large BMP character maps could wrap format 4's 16-bit length; U+FFFF mappings collided with its terminator. Use format 12 in both cases and reject code points outside Unicode.

Encode synthesized font names as UTF-16BE, limit PostScript names to valid characters and 63 bytes, and share repeated name strings. Validate name lengths, table tags/counts and output offsets before narrowing. Shorten the writer's API comments.

Validation: 63 targeted font/PDF-font tests and three PDF corpus cases pass. Three focused regressions exercise the format-size boundary, Unicode/name limits and invalid directories. Name constraints follow the OpenType name specification.

@andiwand
andiwand force-pushed the review/38-sfnt-cmap-bounds branch from e1ebcf7 to f470f38 Compare October 5, 2026 11:03
Base automatically changed from review/38-sfnt-cmap-bounds to main October 5, 2026 11:13
andiwand and others added 3 commits October 5, 2026 13:14
A std::string_view converts to std::string only explicitly, so the copy
initialization from table_data did not compile, and main did not build.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gb1fLafqqzehpqPuU6uBfn
A CFF name may hold any bytes, and the UTF-16 conversion of the name table
threw on them, so the font could not be written. Invalid sequences now
become U+FFFD. The pua_cmap comment again says why an entry past
numGlyphs is dropped.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gb1fLafqqzehpqPuU6uBfn
@andiwand
andiwand force-pushed the review/39-sfnt-serialization branch from 8bb6c57 to 53fde49 Compare October 5, 2026 11:31
@andiwand
andiwand merged commit b5c1014 into main Oct 5, 2026
23 checks passed
@andiwand
andiwand deleted the review/39-sfnt-serialization branch October 5, 2026 11:50
andiwand added a commit that referenced this pull request Oct 5, 2026
The embedded fonts of the PDF outputs changed with #1057. Only the font
data URIs differ.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gb1fLafqqzehpqPuU6uBfn
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.

1 participant