Skip to content

Fix duplicate postscript names for color layer glyphs#1117

Merged
anthrotype merged 1 commit into
mainfrom
color-postscript-names
Nov 15, 2025
Merged

Fix duplicate postscript names for color layer glyphs#1117
anthrotype merged 1 commit into
mainfrom
color-postscript-names

Conversation

@anthrotype

Copy link
Copy Markdown
Member

Color layer glyphs (e.g., "Acaron.color0", "Acaron.color1") were getting duplicate postscript names instead of unique ones with the .colorN suffix preserved.

The bug occurred because when creating color layer glyphs, to_ufo_glyph() was copying unicode values from the parent glyph. This caused glyphdata.get_glyph() to return the base glyph's production name via unicode lookup, losing the .colorN suffix:

Before:

  Acaron          -> uni01CD
  Acaron.color0   -> uni01CD
  Acaron.color1   -> uni01CD

After:

  Acaron          -> uni01CD
  Acaron.color0   -> uni01CD.color0
  Acaron.color1   -> uni01CD.color1

Color layer glyphs (e.g., "Acaron.color0", "Acaron.color1") were
getting duplicate postscript names instead of unique ones with the
.colorN suffix preserved.

The bug occurred because when creating color layer glyphs, to_ufo_glyph()
was copying unicode values from the parent glyph. This caused
glyphdata.get_glyph() to return the base glyph's production name via unicode
lookup, losing the .colorN suffix:

Before:
  Acaron          -> uni01CD
  Acaron.color0   -> uni01CD
  Acaron.color1   -> uni01CD

After:
  Acaron          -> uni01CD
  Acaron.color0   -> uni01CD.color0
  Acaron.color1   -> uni01CD.color1

The fix adds an explicit is_color_layer_glyph parameter to to_ufo_glyph()
to prevent setting unicode values on color layer glyphs, which avoids both
duplicate unicode mappings and ensures glyphdata.get_glyph() is called with
empty unicodes to preserve the .colorN suffix.

This also removes the now-redundant "ufo_glyph.unicodes = []" assignments
in color_layers.py, since unicodes are never set in the first place for
color layer glyphs.
@anthrotype anthrotype force-pushed the color-postscript-names branch from 94fc08d to bea3f75 Compare November 15, 2025 01:58
@anthrotype

Copy link
Copy Markdown
Member Author

you may argue that postscript names are useless in particular for these glyphs which are never going to appear in a run of text, but are simply drawn as COLR layers of other color base glyphs... But the problem is, only some of these color layer glyphs would get the duplicate (un-suffixed) postscript name (the ones with a unicode), whereas others like "caroncomb.alt" which doesn't have a unicode to begin with, would get the suffixed postscript name ""caroncomb.alt.color0" etc.

This is inconsistent and hard/ugly to replicate in fontc. We can either make sure that all color layer glyphs keep their .colorN suffix, or we deliberately strip it from all. I chose the former, because it appeared like an oversight rather than intentional.

@anthrotype anthrotype merged commit a045b48 into main Nov 15, 2025
11 checks passed
@anthrotype anthrotype deleted the color-postscript-names branch November 15, 2025 14:46
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.

2 participants