Repository navigation
Map glyph names with suffixes or ligature components to Unicode (issue 22410) - #22411
Closed
fushanbobfan wants to merge 1 commit into
Closed
fushanbobfan wants to merge 1 commit into
fushanbobfan wants to merge 1 commit into
Conversation
…e 22410)
When a simple font has no ToUnicode entry for a code, its text comes from the
glyph name. Names such as `c.sc`, `T_h.alt` and `uni00E9.sc` were looked up
whole, matched nothing, and the code was then read as its own character, so
the word drawn as "nicht" was extracted as "ni!ht".
When none of the existing lookups give a mapping, the name is now mapped as
described in section 2 of the Adobe Glyph List Specification: everything from
the first period on is dropped, the rest is split at underscores, and each
component is mapped through the glyph list, as a `uni` name with one or more
groups of four hexadecimal digits, or as a `uXXXX{XX}` name.
The result is only used when every component maps, so names like `cid_12`
remain unmapped.
This also fixes the figures in issue10640.pdf, whose glyphs are named `one.os`,
`two.os` and so on; the unit test expected them as "\x81", "\x82" and "\x80".
Collaborator
|
Sorry, but that issue really does not seem like a good fit for a first-time contributor who appears to just submit fully AI generated code (even more so when according to #22411 (comment) you didn't even bother running the full test-suite). |
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.
Fixes #22410
When a simple font has no ToUnicode entry for a code, its text comes from the glyph name. Names such as
c.sc,T_h.altanduni00E9.scwere looked up whole, matched nothing, and the code was then read as its own character, so the word drawn as "nicht" in the issue's file was extracted as "ni!ht".When none of the existing lookups give a mapping, the name is now mapped as described in section 2 of the Adobe Glyph List Specification: everything from the first period on is dropped, the rest is split at underscores, and each component is mapped through the glyph list, as a
uniname with one or more groups of four hexadecimal digits, or as auXXXX{XX}name. The result is only used when every component maps, so names likecid_12remain unmapped. The existing lookups, including theCdd{d}handling and its re-parse, run first and are unchanged.Testing:
api_spec.jstest withissue22410.pdf, the reduced file attached to the issue:getTextContentgivesni!ht "e caf#onmasterandnicht The caféwith this patch.unicode_spec.jscases for the helper (suffixes, ligature components, multi-groupuninames, and names that must stay unmapped, such ascid_12, lowercase hex and surrogates).\x81,\x82and\x80where the page shows "1", "2" and "0"; that font's figures are namedone.os,two.os,zero.osand so on, so the expectations now contain the digits.npx gulp unittestclion Windows: 1806 specs, 0 failures, 82 pending;npx eslintandnpx prettier --checkpass on the changed files.toFontCharfromtoUnicode, so fonts whose glyph names now map may draw a different substitute glyph in the ref tests.