Skip to content

Commit

Permalink
WIP layers
Browse files Browse the repository at this point in the history
  • Loading branch information
belluzj committed Oct 31, 2017
1 parent 973db18 commit e29cc36
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Lib/glyphsLib/builder/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ def masters(self):

assoc_id = layer.associatedMasterId
if assoc_id != layer.layerId:
# FIXME: (jany) is it allowed to have a layer with no name?
# why is it not exported?
if layer_name is not None:
supplementary_layer_data.append(
(assoc_id, glyph_name, layer_name, layer))
Expand Down
10 changes: 7 additions & 3 deletions Lib/glyphsLib/builder/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ def to_glyphs_layer(self, ufo_layer, glyph, master):
# TODO: (jany) add lib attribute to find foreground by layer id
foreground_name = ufo_layer.name[:-len('.background')]
foreground = next(
(l for l in glyph.layers if l.name == foreground_name), None)
(l for l in glyph.layers
if l.name == foreground_name and l.associatedMasterId == master.id
), None)
if foreground is None:
foreground = self.glyphs_module.GSLayer()
foreground.name = foreground_name
Expand All @@ -47,8 +49,10 @@ def to_glyphs_layer(self, ufo_layer, glyph, master):
# Background layers don't have an associated master id nor a name nor an id
foreground.background = layer
else:
layer = next(
(l for l in glyph.layers if l.name == ufo_layer.name), None)
layer = next((
l for l in glyph.layers
if l.name == ufo_layer.name and l.associatedMasterId == master.id),
None)
if layer is None:
layer = self.glyphs_module.GSLayer()
layer.associatedMasterId = master.id
Expand Down

0 comments on commit e29cc36

Please sign in to comment.