LettError/MutatorMath

Glyphs with multiple unicode values loss them

Closed this issue · 3 comments

UFO glyphs with multiple unicode values will result in a warning like:

Multiple unicode values for glyph space: 32, 160

and the glyph in the generated instance will have no Unicode values at all, breaking the font.

Multiple unicode values are supported in UFO and shouldn’t cause a warning. I check the code and it seems that there are multiple places that assume there is always one unicode value per glyph.

Sorry I was distracted and missed this issue. It looks like this needs to be fixed. The rationale for the current code, mutator tries to establish the right unicode value for a glyph by looking at all the masters. These might vary and the solution was to warn and hope for an external fix. I'll review your changes.

What if:

  • glyph.unicodes becomes the superset of all unique unicode values in all masters
  • glyph.unicode will be the unicode value from the neutral glyph
  • report clashes, absences

In practice there seem to be few occasions of actual clashes, but sometimes there are masters with the occasional value missing. Making a superset is more forgiving for situations with some missing values.

  • for glyphs with multiple unicode values, does the order matter?
  • if the neutral glyph has no unicode, but other masters do, it could pick the first available value from glyph.unicodes if there are any.

The order is not important, they will end up as multiple entries in the cmap table. One way to keep backward compatibility is to do something similar to defcon; keep unicode that is a shorthand for the first entry in the unicodes list.