Repository navigation
fix(tounicode): read cmap-less core Windows subsets by their own glyph order, and their blank glyphs as spaces - #618
Merged
Conversation
…h order, and their blank glyphs as spaces A TrueType subset with no cmap, glyph names or ToUnicode is decoded by the standard Macintosh glyph order (#522). The core Windows fonts (Arial, Times New Roman, Courier New, Verdana, Georgia, Tahoma) use a variant of it: no nonbreakingspace at 172 and no apple at 210, Euro in the place of currency, overscore and middot at the end. Read through the Macintosh order, every glyph from 172 on came out as its neighbour: curly quotes as dashes, apostrophes as opening quotes, en dashes as œ. The variant is now chosen by the font's own advances: an accented letter advances like its base letter, which both orders keep at the same slots, so each order is scored by how many of its accented slots from 172 on fit. The Windows order is taken only when it fits more and misfits fewer; equal evidence keeps the Macintosh order. Past the 258 named slots a glyph has no name to read. One that paints nothing but advances now reads as a space: the core Windows fonts draw U+2000-U+200A as a one-point outline, and Word justifies lines with the en and em spaces (glyphs 3024 and 3025 in Arial). Only glyphs with an outline record count, so the slots a subset dropped stay unmapped. On ten Sourcewell contract packets embedded in city agenda PDFs, the U+FFFD share falls from 1-6% to 0.0% (santafe 0.1%, an unrelated font), and the 40 pages fulton's packet sent to OCR as garbled text read as text. The pdf-evals corpus is unchanged (196/196). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
All reported issues were addressed across 3 files
Shadow auto-approve: would auto-approve with 1 open P3 issue. Fixes cmap-less TrueType decoding for core Windows font subsets by selecting the Windows glyph order via advances and mapping blank glyphs to spaces, with tests; bounded bug fix.
Fix all with cubic | Re-trigger cubic
…t only the no-break space Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
0 issues found across 1 file (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Shadow auto-approve: would auto-approve. Fixes decoding of cmap-less TrueType subsets for core Windows fonts: selects the Windows glyph-order variant by advances and maps blank glyphs to spaces, with comprehensive tests and changelog.
Re-trigger cubic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#522 decodes a TrueType subset that has no
cmap, no glyph names and no ToUnicode through the standard Macintosh glyph order. Two gaps were left for subsets of the core Windows fonts, which Word embeds this way. Ten Sourcewell contract packets, embedded in city agenda PDFs that search-index flagged for garbage text, all show both gaps.nonbreakingspaceat 172 and noappleat 210,Euroin the place ofcurrency, andoverscoreandmiddotat the end. Read through the Macintosh order, every glyph from 172 on came out as its neighbour:“N/A”as—N/A“,company’sascompany‘s, en dashes asœ.Proposer�Legal�Name), and the pages went to OCR assuspected_garbled_text.Results
On the 11 PDFs from the report that could be downloaded (the ten Sourcewell packets, plus the Texas House rules PDF, which was already clean):
pages_needing_ocr“/”œOn the pdf-evals corpus the fix moves one snapshot: the Navigating AI book's chatbot figures, set in an
ArialMTsubset of this kind, readOpenAI’s,don’t,Anne’sand seven more where they read‘. It is synced in firecrawl/pdf-evals#114. A control run of main's binary moves nothing, and no curated score row moves.Monospaced Windows fonts such as Courier New still fail the existing
i/lagainstm/wcorroboration, so they never reach this path.Tests
“N/A”,–,’and€through the Windows order;These pass:
cargo fmtcargo clippy -- -D warningscargo testbench.py testin pdf-evals (one snapshot moved, synced in firecrawl/pdf-evals#114)🤖 Generated with Claude Code
Summary by cubic
Fixes cmap-less TrueType decoding for core Windows font subsets, which previously read every glyph from slot 172 on as its neighbor (
“N/A”as—N/A“) and rendered blank justification spaces as U+FFFD garbage.Written for commit baa841b. Summary will update on new commits.