Skip to content

Ignore the suffix of a glyph name when mapping a simple font to Unicode (issue 22410) - #22412

Closed
arxhr007 wants to merge 1 commit into
mozilla:masterfrom
arxhr007:glyph-name-suffix-to-unicode
Closed

arxhr007 wants to merge 1 commit into
mozilla:masterfrom
arxhr007:glyph-name-suffix-to-unicode

Conversation

@arxhr007

@arxhr007 arxhr007 commented Nov 1, 2026

Copy link
Copy Markdown

Fixes #22410.

The Adobe Glyph List Specification says that everything from the first period onwards in a glyph name is a suffix (for example c.sc, T_h.alt or one.os), which doesn't change the character(s) of the glyph: https://github.com/adobe-type-tools/agl-specification#2-the-mapping-algorithm

PartialEvaluator._simpleFontToUnicode didn't do that, so the text of simple fonts with such /Differences names was extracted as the character code itself. The glyphs were rendered correctly, but text selection, search and getTextContent returned the wrong characters.

This patch looks up the name without the suffix, if the full name isn't in the glyph list, and then continues with the existing heuristics using that name. This means that c.sc is c, uni00E9.sc goes through the existing uniXXXX handling, and T_h.alt reaches the existing T_h ligature case. A name that starts with a period (.notdef) is left alone.

I did not add the AGL rule for ligature names in general (a_b is ab) since it isn't needed for this issue, and I'd rather keep this change small.

Test:

  • New issue22410.pdf (the file from the issue, 3 KB) and an api_spec.js test that expects nicht The café; it fails without the change (ni!ht "e caf#).
  • The issue 10640 test expected the same bug. That PDF uses one.os, two.os and zero.os, and its test expected the control characters \x81, \x82 and \x80 where the page has 1, 2 and 0 (for example Directory [\x81] and version \x82.\x80). With this patch the text is Directory [1] and version 2.0, so I updated that expectation.
  • The real-world file from the issue (arbeitgeberbescheinigung-max-mustermann.pdf) now has Nein, trifft nicht zu on pages 2 and 3, where it was Nein, trifft ni!ht zu.
  • The full unit tests give the same results as master apart from this (the failures that remain are in tests whose PDFs I hadn't downloaded). eslint is clean.

This change was prepared with the help of an AI coding assistant (Devin CLI) and reviewed by me.

…de (issue 22410)

The Adobe Glyph List Specification says that everything from the first period
onwards in a glyph name is a suffix, e.g. `c.sc`, `T_h.alt` or `one.os`, which
doesn't change the character(s) of the glyph. Hence the text of such glyphs
was previously extracted as the character code itself, which broke e.g. text
selection and search, even though the glyphs were rendered correctly.

The existing `issue10640.pdf` test expected exactly this wrong text, i.e. the
glyph names `one.os`/`two.os`/`zero.os` ended up as the control characters
`\x81`/`\x82`/`\x80` instead of the digits `1`/`2`/`0`, so update it.
@Snuffleupagus

Copy link
Copy Markdown
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.

@arxhr007
arxhr007 deleted the glyph-name-suffix-to-unicode branch November 1, 2026 17:19
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.

[Bug]: Text of an embedded simple font is read as the code's own character when the glyph name has a suffix (c.sc) or is an unknown ligature (T_h.alt)

2 participants