Repository navigation
Conversation
A non-embedded CIDFontType2 font with Identity encoding and no CIDToGIDMap selects glyphs of the named system font by index. The substitute is a name-keyed CFF with a different glyph order, so using the CID as its glyph index drew the wrong glyphs. TrueType core fonts such as Arial keep the standard Macintosh glyph order for their first 258 glyphs. For such fonts, map CIDs to Unicode through a compile-time table of that order, so the substitute draws glyphs by character. Type0 fonts also now pick the substitute's weight and style from their base font name instead of always regular Helvetica. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conformance readsDocuments that Safe-PDF reads differently from the base commit, compared with PDFium. A read pdf.js corpus1008 documents compared with Regressions
840 documents of the PDFium corpus read as on Details are in the job summaries of the workflow run. Rerun a case locally with |
This branch has not been deployed
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.
Problem
The
fx/FRC_8.2.4_part1/*cover pages (in the #479 cluster) drew "Foxit Ü^æå^¦ or Foxit…" where the text should read "Foxit Reader or Foxit PhantomPDF".The font is a non-embedded Type0
Arial,Boldwith an Identity-H encoding. Its descendant is a CIDFontType2 with noFontFile2,CIDToGIDMaporToUnicode. Its CIDs are glyph indices into the real Arial Bold. Safe-PDF used each CID directly as a glyph index into the bundledFoxitSans.cffsubstitute, whose glyph order is unrelated, and it always picked the regular weight for Type0 substitutes.Change
New
cid_to_unicode.rswith aCidToUnicodeenum:Collectionwraps the existing runtime CJK maps.StandardGlyphOrderreads a compile-time[Option<char>; 258]table that maps the standard Macintosh glyph order to Unicode.TrueType core fonts such as Arial, Times New Roman and Courier New keep that order for their first 258 glyphs.
CidFontSpecusesStandardGlyphOrderfor a non-embedded CIDFontType2 font that has noCIDToGIDMapand names a non-symbolic core font (newStandard14Font::has_standard_glyph_order). The text engine already picks substitute glyphs by Unicode, so the substitute now draws the correct characters.PdfFontSpec::substitute_standard14takes a Type0 font's weight and style from its base font name, soArial,Boldgets the bold substitute.PDFium draws its own wrong text here ("FYUXYf"), so these pages still differ from the reference. The rest of their difference is the logo image, which PDFium downscales more softly.
Testing
cargo clippy --all --workspaceandcargo fmt --checkare clean.cargo test -p pdf-font -p pdf-text-enginepasses.cargo conformance reproof [conformance] Render differs: different shape in image (RGBA8888) #479 and [conformance] Render differs: different shape in text #480 againstmain: only the 14FRC_8.2.4pages changed (mismatch 0.623% → 0.515%), and they now read "Foxit Reader or Foxit PhantomPDF". All other pages are unchanged.🤖 Generated with Claude Code