Skip to content

Commit

Permalink
Merge pull request #974 from googlefonts/fix-973
Browse files Browse the repository at this point in the history
Fix color component layers
  • Loading branch information
anthrotype authored Jan 29, 2024
2 parents ed02363 + 63c88be commit ce6d451
Show file tree
Hide file tree
Showing 3 changed files with 628 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Lib/glyphsLib/builder/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ def to_ufo_components(self, ufo_glyph, layer):
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()
l
for l in component_glyph.layers
if l._is_color_palette_layer()
and l.associatedMasterId == layer.associatedMasterId
]
for i, l in enumerate(color_layers):
if l._color_palette_index() == layer._color_palette_index():
Expand Down
20 changes: 20 additions & 0 deletions tests/builder/builder_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,26 @@ def test_glyph_color_palette_layers_no_unicode_mapping(ufo_module):
assert ufo["a.color1"].unicode is None


def test_glyph_color_layers_components_2(ufo_module):
filename = os.path.join(
os.path.dirname(__file__), "..", "data", "ColorComponents.glyphs"
)
with open(filename) as f:
font = glyphsLib.load(f)

ds = glyphsLib.to_designspace(font, minimize_glyphs_diffs=True)
bold_layer0 = ds.sources[1].font.layers["color.0"]
bold_layer1 = ds.sources[1].font.layers["color.1"]
assert [c.baseGlyph for c in bold_layer0["Aacute"].components] == [
"A.color0",
"acutecomb.color0",
]
assert [c.baseGlyph for c in bold_layer1["Aacute"].components] == [
"A.color1",
"acutecomb.color1",
]


def test_glyph_color_palette_layers_explode(ufo_module):
font = generate_minimal_font()
glypha = add_glyph(font, "a")
Expand Down
Loading

0 comments on commit ce6d451

Please sign in to comment.