Skip to content

fix(font): validate CFF output and preserve fractional widths - #1061

Merged
andiwand merged 2 commits into
mainfrom
review/43-cff-builder
Oct 5, 2026
Merged

andiwand merged 2 commits into
mainfrom
review/43-cff-builder

Conversation

@andiwand

@andiwand andiwand commented Oct 4, 2026 •

Copy link
Copy Markdown
Member

🤖 Generated with Claude Code

The CFF builder narrowed counts, SIDs and offsets without checking and cast width operands directly to integers. Validate glyph sets and representable output sizes, encode finite real DICT operands, and preserve fractional charstring widths until the final advance is computed.

Reuse the CFF standard glyph-name IDs instead of writing those names into every font's String INDEX. This reduces generated font data while leaving glyph order unchanged. The Type1 conversion keeps the first charstring of a repeated glyph name, because the builder now refuses duplicate names.

Validation: 50 targeted CFF, Type1, font-file and PDF-font tests pass. Two focused regressions cover fractional arithmetic, standard-name reuse, non-finite values and invalid glyph sets. The committed standard-string tables match their generator and contain 391 unique names.

@andiwand
andiwand force-pushed the review/42-type1-charstrings branch from 8db1ac8 to 87186bf Compare October 5, 2026 12:48
Base automatically changed from review/42-type1-charstrings to main October 5, 2026 12:59
andiwand and others added 2 commits October 5, 2026 14:59
build_cff now refuses duplicate glyph names, and Type1Font keeps every
CharStrings entry, so a font that repeats a name lost all its glyphs.
to_cff now keeps the first charstring of a repeated name. dict_number
uses util::number::to_integer. The too-many-glyphs test now starts with
.notdef, so it fails on the count and not on the missing .notdef.

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/43-cff-builder branch from 772a392 to 2db849a Compare October 5, 2026 13:05
@andiwand
andiwand merged commit 875062a into main Oct 5, 2026
22 of 23 checks passed
@andiwand
andiwand deleted the review/43-cff-builder branch October 5, 2026 13:16
andiwand added a commit that referenced this pull request Oct 5, 2026
The PDF outputs changed with #1060, #1061 and #1068: Type1 and CFF font
data, and embedded PNGs split into 64 KiB IDAT chunks. Only 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