Skip to content

Commit

Permalink
Merge pull request #939 from the-type-founders/bs-color-layer-glyph-m…
Browse files Browse the repository at this point in the history
…apping

Do not set Unicode values for each layer in a color glyph.
  • Loading branch information
anthrotype authored Sep 4, 2023
2 parents 8577f83 + 149fcba commit 8c0157e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Lib/glyphsLib/builder/color_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ def _to_ufo_color_palette_layers(builder, master, layerMapping):
ufo_layer = builder.to_ufo_layer(glyph, masterLayer)
ufo_glyph = ufo_layer.newGlyph(layerGlyphName)
builder.to_ufo_glyph(ufo_glyph, layer, glyph)
# Remove Unicode mapping from each color layer to avoid
# duplicate entries.
ufo_glyph.unicodes = []
colorLayers.append((layerGlyphName, colorId))
layerMapping[glyph.name] = colorLayers

Expand Down
22 changes: 22 additions & 0 deletions tests/builder/builder_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1188,6 +1188,28 @@ def test_glyph_color_layers_components(ufo_module):
assert len(ufo.layers["color.3"]["a"]) == 0


def test_glyph_color_palette_layers_no_unicode_mapping(ufo_module):
font = generate_minimal_font()
glypha = add_glyph(font, "a")

glypha.unicode = "0061"

color0 = GSLayer()
color1 = GSLayer()
color0.name = "Color 0"
color1.name = "Color 1"

glypha.layers.append(color0)
glypha.layers.append(color1)

ds = to_designspace(font, ufo_module=ufo_module, minimal=True)
ufo = ds.sources[0].font

assert ufo["a"].unicode == 97
assert ufo["a.color0"].unicode is None
assert ufo["a.color1"].unicode is None


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

0 comments on commit 8c0157e

Please sign in to comment.