Skip to content

fix(pdf): do not embed a CFF font of only .notdef - #925

Merged
andiwand merged 2 commits into
mainfrom
pdf/cff-top-dict
Sep 23, 2026
Merged

andiwand merged 2 commits into
mainfrom
pdf/cff-top-dict

Conversation

@andiwand

@andiwand andiwand commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

🤖 Generated with Claude Code

Summary

The OTS check of build-test failed on main after #922 added ReichaCompositionslehreB2Teil4.pdf to the test data:

FAIL .../ReichaCompositionslehreB2Teil4.pdf/document.html: odr-f1
     ERROR: CFF : Failed to parse Top DICT Data

The font is HiddenHorzOCl, the hidden OCR text layer of the scan. Its CharStrings INDEX holds only .notdef. OTS rejects a CFF table with fewer than two glyphs (charstring_index->count < 2 in ots/src/cff.cc), and it reports this as a Top DICT error. cff::wrap_to_otf now throws for such a font, so font_is_usable renders the text with a substitute. The font draws no glyph, so no pixel changes.

Reference output

This PR also regenerates the references for the stack #920 to #924, as those PRs said. #911 and #916/#917 did not regenerate theirs either, so the new references include those changes too.

files cause
public 34 + 4 resources/ the viewport minimum-scale (#911), the pdf selection style (#916/#917), the frontend scripts (#912 to #918)
private 1112 + 4 resources/ the same, plus the two CCITT scans and the five corpus files (#920), the Intermediate cover (#921), and the Reicha scan (this PR)

If I apply the known CSS changes to the old references, only the files that the stack and this PR explain still differ. No file is added or removed.

  • OpenDocument.test.output 055e7ec, OpenDocument.test-private.output 509b819, both on main.

Test

  • CffFontTest.WrapRejectsAFontOfOnlyNotdef.
  • The full suite passes (1848 tests). check_fonts.py on the Reicha output: 0 rejected by OTS. The changed files compile with -Werror.

andiwand and others added 2 commits September 23, 2026 20:49
OTS rejects a `CFF ` table whose CharStrings INDEX holds fewer than two
glyphs. The hidden OCR font of the Reicha scan is such a font, so the
OTS check in CI failed. `cff::wrap_to_otf` now throws for it, and
`font_is_usable` renders the text with a substitute.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MKmQRa5uj4MfJxXfbA3crz
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MKmQRa5uj4MfJxXfbA3crz
@andiwand
andiwand merged commit 561d581 into main Sep 23, 2026
27 checks passed
@andiwand
andiwand deleted the pdf/cff-top-dict branch September 23, 2026 18:54
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