Map MSTT GNN/gNNN/cidNNN glyph-index names to Unicode - #4
Open
lfoppiano wants to merge 1 commit into
Open
Conversation
Resolve glyph-index-named glyphs (hex 'GNN' MSTT and decimal 'gNNN'/'cidNNN'/ 'glyphNNN'/'indexNNN'/'cNNN') through the standard Macintosh glyph ordering before the pass-2 hex/numeric heuristic, which otherwise garbles MSTT subset fonts with no ToUnicode (e.g. 'Received' -> '4GEGKXG'). Adds FoFiTrueType::getMacGlyphName() to expose the 258-entry Mac glyph table.
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
Recover real Unicode for subset fonts whose glyphs are named by glyph index rather than by a semantic character name, which xpdf's pass-2 heuristic otherwise misreads (e.g.
G34→ the literal'4',g50→'2'), garbling body text in MSTTMSTT31c…fonts that carry noToUnicode.Changes
FoFiTrueType::getMacGlyphName(gid)— exposes the existing 258-entry standard Macintosh glyph-name table (macGlyphNames), bounds-checked.GfxFont.cc:mapHexGlyphIndexName()— MSTT uppercase-G+ hex index naming (glyph 0 /.notdefdropped, so the index is offset by one; optional.suffixignored).mapGlyphIndexName()— decimal index naming with a longest-prefix-first, case-insensitive prefix set (glyph,index,cid,g,c).Gfx8BitFontconstructor: tried before the generic hex/numeric heuristic (and the Type 3 identity fallback), resolving the index through the standard Mac glyph ordering to recover the intended Unicode.Validated downstream
Built into
pdfalto(see kermitt2/pdfalto#234),degruyterMSTT documents now extractReceived/Contributionsinstead of the Caesar-shifted4GEGKXG/8QNWOG.