Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with color components #973

Closed
simoncozens opened this issue Jan 29, 2024 · 4 comments
Closed

Problems with color components #973

simoncozens opened this issue Jan 29, 2024 · 4 comments

Comments

@simoncozens
Copy link
Collaborator

This glyphs file: BadColor.glyphs.gz has two masters, each with two color layers. I would expect these layers to be exported as ".color0" and ".color1". However, the names of some (not all!) component glyphs used in these masters are incorrect:

$ glyphs2ufo BadColor.glyphs
$ cat BadColor-Thin.ufo/glyphs.color.1/A_acute.glif
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="Aacute" format="2">
  <advance width="500"/>
  <unicode hex="00C1"/>
  <anchor x="685" y="10" name="ogonek"/>
  <anchor x="355" y="708" name="top"/>
  <outline>
    <component base="A.color1"/>
    <component base="acutecomb.color2" xOffset="370" yOffset="208"/>
  </outline>

There is no color2, so the font does not compile.

@anthrotype
Copy link
Member

the issue must be somewhere here:

for index, component in enumerate(layer.components):
component_name = component.name
if layer._is_color_palette_layer():
# Glyphs handles components for color layers in a special way. If
# the component glyph has color layers of its own, the component
# use the first color layer with the same color index, otherwise it
# fallback to the default layer. We try to do that here as well.
font = layer.parent.parent
component_glyph = font.glyphs[component_name]
color_layers = [
l for l in component_glyph.layers if l._is_color_palette_layer()
]
for i, l in enumerate(color_layers):
if l._color_palette_index() == layer._color_palette_index():
if l.layerId != l.associatedMasterId:
# If it is not a master layer, we rename it in
# _to_ufo_color_palette_layers(), so we reference the
# same name here.
component_name += f".color{i}"
break

@simoncozens
Copy link
Collaborator Author

Yep, that looks suspicious. I will try to fix.

@anthrotype
Copy link
Member

thanks. I tried to understand what was going on but failed so far, happy to pass it to you

@anthrotype
Copy link
Member

Fixed by #974

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

No branches or pull requests

2 participants