From 755ffa481ac95567b1ce6ea5818bbf7785aa2676 Mon Sep 17 00:00:00 2001 From: Denis Moyogo Jacquerye Date: Fri, 29 May 2020 06:29:45 +0100 Subject: [PATCH 1/9] test_duplicate_supplementary_background_layers --- tests/builder/builder_test.py | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/builder/builder_test.py b/tests/builder/builder_test.py index 160beb0a2..a89114417 100644 --- a/tests/builder/builder_test.py +++ b/tests/builder/builder_test.py @@ -869,6 +869,42 @@ def test_duplicate_supplementary_layers(self): ) captor.assertRegex("Duplicate glyph layer name") + def test_duplicate_supplementary_background_layers(self): + """Test glyph background layers with same name.""" + font = generate_minimal_font() + glyph = GSGlyph(name="a") + font.glyphs.append(glyph) + layer = GSLayer() + layer.layerId = font.masters[0].id + # skip layer.width = 0 + glyph.layers.append(layer) + sublayer = GSLayer() + sublayer.associatedMasterId = font.masters[0].id + # skip sublayer.width = 0 + sublayer.name = "SubLayer" + sublayer.background.width = 0 + glyph.layers.append(sublayer) + sublayer = GSLayer() + sublayer.associatedMasterId = font.masters[0].id + # skip sublayer.width = 0 + sublayer.name = "SubLayer" + sublayer.background.width = 0 + glyph.layers.append(sublayer) + with CapturingLogHandler(builder.logger, level="WARNING") as captor: + ufo = self.to_ufos(font)[0] + + self.assertEqual( + [l.name for l in ufo.layers], + [ + "public.default", + "SubLayer", + "SubLayer.background", + "SubLayer #1", + "SubLayer #1.background", + ], + ) + captor.assertRegex("Duplicate glyph layer name") + def test_glyph_lib_Export(self): font = generate_minimal_font() glyph = add_glyph(font, "a") From 8a2d83862ddce3e570b86fa44ac61860b1503631 Mon Sep 17 00:00:00 2001 From: Denis Moyogo Jacquerye Date: Sat, 27 Feb 2021 23:07:15 +0000 Subject: [PATCH 2/9] Background of layers with same name --- Lib/glyphsLib/builder/glyph.py | 2 +- Lib/glyphsLib/builder/layers.py | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Lib/glyphsLib/builder/glyph.py b/Lib/glyphsLib/builder/glyph.py index 7e3da876d..3c842f042 100644 --- a/Lib/glyphsLib/builder/glyph.py +++ b/Lib/glyphsLib/builder/glyph.py @@ -310,7 +310,7 @@ def to_ufo_glyph_background(self, glyph, layer): return background = layer.background - ufo_layer = self.to_ufo_background_layer(layer) + ufo_layer = self.to_ufo_background_layer(glyph, layer) new_glyph = ufo_layer.newGlyph(glyph.name) width = background.userData[BACKGROUND_WIDTH_KEY] diff --git a/Lib/glyphsLib/builder/layers.py b/Lib/glyphsLib/builder/layers.py index e6e1b6dd1..1e919f793 100644 --- a/Lib/glyphsLib/builder/layers.py +++ b/Lib/glyphsLib/builder/layers.py @@ -49,14 +49,29 @@ def to_ufo_layer(self, glyph, layer): return ufo_layer -def to_ufo_background_layer(self, layer): +def to_ufo_background_layer(self, glyph, layer): ufo_font = self._sources[layer.associatedMasterId or layer.layerId].font if layer.associatedMasterId == layer.layerId: layer_name = "public.background" else: layer_name = layer.name + ".background" + if layer_name not in ufo_font.layers: background_layer = ufo_font.newLayer(layer_name) + elif layer_name in ufo_font.layers and glyph.name in ufo_font.layers[layer_name]: + self.logger.warning( + "%s %s: Glyph %s, layer %s: Duplicate glyph layer name", + ufo_font.info.familyName, + ufo_font.info.styleName, + glyph.name, + layer_name, + ) + n = 1 + new_layer_name = layer_name + while new_layer_name in ufo_font.layers: + new_layer_name = layer.name + " #" + repr(n) + ".background" + n += 1 + background_layer = ufo_font.newLayer(new_layer_name) else: background_layer = ufo_font.layers[layer_name] return background_layer From 69a9df646b7124739461aa4ef62eec6bd3347eea Mon Sep 17 00:00:00 2001 From: Denis Moyogo Jacquerye Date: Sat, 27 Feb 2021 23:15:59 +0000 Subject: [PATCH 3/9] Use f-strings --- Lib/glyphsLib/builder/layers.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/Lib/glyphsLib/builder/layers.py b/Lib/glyphsLib/builder/layers.py index 1e919f793..c9bde74df 100644 --- a/Lib/glyphsLib/builder/layers.py +++ b/Lib/glyphsLib/builder/layers.py @@ -27,16 +27,13 @@ def to_ufo_layer(self, glyph, layer): ufo_layer = ufo_font.newLayer(layer.name) elif layer.name in ufo_font.layers and glyph.name in ufo_font.layers[layer.name]: self.logger.warning( - "%s %s: Glyph %s, layer %s: Duplicate glyph layer name", - ufo_font.info.familyName, - ufo_font.info.styleName, - glyph.name, - layer.name, + f"{ufo_font.info.familyName} {ufo_font.info.styleName}: " + f"Glyph {glyph.name}, layer {layer.name}: Duplicate glyph layer name", ) n = 1 new_layer_name = layer.name while new_layer_name in ufo_font.layers: - new_layer_name = layer.name + " #" + repr(n) + new_layer_name = f"{layer.name} #{n!r}" n += 1 ufo_layer = ufo_font.newLayer(new_layer_name) else: @@ -54,22 +51,19 @@ def to_ufo_background_layer(self, glyph, layer): if layer.associatedMasterId == layer.layerId: layer_name = "public.background" else: - layer_name = layer.name + ".background" + layer_name = f"{layer.name}.background" if layer_name not in ufo_font.layers: background_layer = ufo_font.newLayer(layer_name) elif layer_name in ufo_font.layers and glyph.name in ufo_font.layers[layer_name]: self.logger.warning( - "%s %s: Glyph %s, layer %s: Duplicate glyph layer name", - ufo_font.info.familyName, - ufo_font.info.styleName, - glyph.name, - layer_name, + f"{ufo_font.info.familyName} {ufo_font.info.styleName}: " + f"Glyph {glyph.name}, layer {layer_name}: Duplicate glyph layer name", ) n = 1 new_layer_name = layer_name while new_layer_name in ufo_font.layers: - new_layer_name = layer.name + " #" + repr(n) + ".background" + new_layer_name = f"{layer.name} #{n!r}.background" n += 1 background_layer = ufo_font.newLayer(new_layer_name) else: From d763522a56b6baa88cfc2a5146801931e4ee63dd Mon Sep 17 00:00:00 2001 From: Denis Moyogo Jacquerye Date: Sun, 28 Feb 2021 23:57:37 +0000 Subject: [PATCH 4/9] Add Glyphs file with Color layers sharing names --- tests/builder/builder_test.py | 77 +++ tests/data/ColorColrCpalFont.glyphs | 999 ++++++++++++++++++++++++++++ 2 files changed, 1076 insertions(+) create mode 100644 tests/data/ColorColrCpalFont.glyphs diff --git a/tests/builder/builder_test.py b/tests/builder/builder_test.py index a89114417..2c274ed14 100644 --- a/tests/builder/builder_test.py +++ b/tests/builder/builder_test.py @@ -905,6 +905,83 @@ def test_duplicate_supplementary_background_layers(self): ) captor.assertRegex("Duplicate glyph layer name") + def test_color_layer_with_background(self): + filename = os.path.join( + os.path.dirname(__file__), "..", "data", "ColorColrCpalFont.glyphs" + ) + with open(filename) as f: + font = glyphsLib.load(f) + ufo = self.to_ufos(font, minimize_glyphs_diffs=False)[0] + + glyph = font.glyphs["I"] + assert { + ( + l.name, + l.lib.get("com.schriftgestaltung.layerId"), + l.lib.get("com.schriftgestaltung.foregroundLayerId"), + ) + for l in ufo.layers + } == { + ("public.default", None, None), + ("Color 0", glyph.layers[1].layerId, None), + ("Color 1", None, None), + ("Color 2", glyph.layers[3].layerId, None), + ("Color 2.background", None, glyph.layers[3].layerId), + ("Color 2 #1", glyph.layers[4].layerId, None), + ("Color 2 #1.background", None, glyph.layers[4].layerId), + ("Color 0 #1", glyph.layers[5].layerId, None), + ("Color 0 #1.background", None, glyph.layers[5].layerId), + } + glyph = font.glyphs["I.001"] + assert { + ( + l.name, + l.lib.get("com.schriftgestaltung.layerId"), + l.lib.get("com.schriftgestaltung.foregroundLayerId"), + ) + for l in ufo.layers + } == { + ("public.default", None, None), + ("Color 1", None, None), + ("Color 2 #1", glyph.layers[2].layerId, None), + ("Color 2 #1.background", None, glyph.layers[2].layerId), + ("Color 2", glyph.layers[3].layerId, None), + ("Color 2.background", None, glyph.layers[3].layerId), + ("Color 0 #1", glyph.layers[4].layerId, None), + ("Color 0 #1.background", None, glyph.layers[4].layerId), + ("Color 0", glyph.layers[5].layerId, None), + } + + font = to_glyphs((ufo,)) + glyph = font.glyphs["I"] + assert [l.name for l in glyph.layers] == [ + "Regular", + "Color 0", + "Color 1", + "Color 2", + "Color 2", + "Color 0", + ] + assert len(glyph.layers[1].background.paths) == 0 + assert len(glyph.layers[2].background.paths) == 0 + assert len(glyph.layers[3].background.paths) == 1 + assert len(glyph.layers[4].background.paths) == 2 + assert len(glyph.layers[5].background.paths) == 1 + glyph = font.glyphs["I.001"] + assert [l.name for l in glyph.layers] == [ + "Regular", + "Color 1", + "Color 2", + "Color 2", + "Color 0", + "Color 0", + ] + assert len(glyph.layers[1].background.paths) == 0 + assert len(glyph.layers[2].background.paths) == 2 + assert len(glyph.layers[3].background.paths) == 1 + assert len(glyph.layers[4].background.paths) == 1 + assert len(glyph.layers[5].background.paths) == 0 + def test_glyph_lib_Export(self): font = generate_minimal_font() glyph = add_glyph(font, "a") diff --git a/tests/data/ColorColrCpalFont.glyphs b/tests/data/ColorColrCpalFont.glyphs new file mode 100644 index 000000000..eac443a09 --- /dev/null +++ b/tests/data/ColorColrCpalFont.glyphs @@ -0,0 +1,999 @@ +{ +.appVersion = "1354"; +DisplayStrings = ( +"I/I.001" +); +date = "2021-02-28 22:39:55 +0000"; +familyName = "Color COLR CPAL Font"; +fontMaster = ( +{ +ascender = 800; +capHeight = 700; +customParameters = ( +{ +name = "Color Palettes"; +value = ( +( +"234,171,0,255", +"234,63,25,255", +"87,13,0,255" +) +); +} +); +descender = -200; +id = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +xHeight = 500; +} +); +glyphs = ( +{ +glyphname = A; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0041; +}, +{ +glyphname = B; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0042; +}, +{ +glyphname = C; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0043; +}, +{ +glyphname = D; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0044; +}, +{ +glyphname = E; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0045; +}, +{ +glyphname = F; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0046; +}, +{ +glyphname = G; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0047; +}, +{ +glyphname = H; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0048; +}, +{ +glyphname = I; +lastChange = "2021-02-28 22:48:46 +0000"; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +paths = ( +{ +closed = 1; +nodes = ( +"185 0 LINE", +"415 0 LINE", +"415 700 LINE", +"185 700 LINE" +); +} +); +width = 600; +}, +{ +associatedMasterId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +layerId = "FBB4A6BE-E06C-4CB3-BA24-527C837D6E11"; +name = "Color 0"; +paths = ( +{ +closed = 1; +nodes = ( +"185 0 LINE", +"415 0 LINE", +"415 700 LINE", +"185 700 LINE" +); +} +); +width = 600; +}, +{ +associatedMasterId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +layerId = "79A3A3AC-9288-47C2-855F-040FC78C65A0"; +name = "Color 1"; +paths = ( +{ +closed = 1; +nodes = ( +"415 0 LINE", +"540 -105 LINE", +"540 595 LINE", +"415 700 LINE" +); +} +); +width = 600; +}, +{ +associatedMasterId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +background = { +paths = ( +{ +closed = 1; +nodes = ( +"310 -105 LINE", +"540 -105 LINE", +"185 0 LINE" +); +} +); +}; +layerId = "71DB9149-5D1A-4B25-9EF3-E1BEC81311FA"; +name = "Color 2"; +paths = ( +{ +closed = 1; +nodes = ( +"310 -105 LINE", +"540 -105 LINE", +"415 0 LINE", +"185 0 LINE" +); +} +); +width = 600; +}, +{ +associatedMasterId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +background = { +paths = ( +{ +closed = 1; +nodes = ( +"455 442 LINE", +"500 397 LINE", +"500 525 LINE", +"455 560 LINE" +); +}, +{ +closed = 1; +nodes = ( +"455 90 LINE", +"500 45 LINE", +"500 173 LINE", +"455 208 LINE" +); +} +); +}; +layerId = "DA3EBD73-82FA-4124-85DD-31E1E78E6FB1"; +name = "Color 2"; +paths = ( +{ +closed = 1; +nodes = ( +"455 40 LINE", +"500 -5 LINE", +"500 555 LINE", +"455 590 LINE" +); +} +); +width = 600; +}, +{ +associatedMasterId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +background = { +paths = ( +{ +closed = 1; +nodes = ( +"348 133 LINE", +"413 133 LINE", +"377 162 LINE", +"312 162 LINE" +); +} +); +}; +layerId = "EF055C20-0F0F-4946-9658-118D85F4B36F"; +name = "Color 0"; +paths = ( +{ +closed = 1; +nodes = ( +"348 -67 LINE", +"413 -67 LINE", +"377 -38 LINE", +"312 -38 LINE" +); +} +); +width = 600; +} +); +unicode = 0049; +}, +{ +glyphname = J; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 004A; +}, +{ +glyphname = K; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 004B; +}, +{ +glyphname = L; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 004C; +}, +{ +glyphname = M; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 004D; +}, +{ +glyphname = N; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 004E; +}, +{ +glyphname = O; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 004F; +}, +{ +glyphname = P; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0050; +}, +{ +glyphname = Q; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0051; +}, +{ +glyphname = R; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0052; +}, +{ +glyphname = S; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0053; +}, +{ +glyphname = T; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0054; +}, +{ +glyphname = U; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0055; +}, +{ +glyphname = V; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0056; +}, +{ +glyphname = W; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0057; +}, +{ +glyphname = X; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0058; +}, +{ +glyphname = Y; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0059; +}, +{ +glyphname = Z; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 005A; +}, +{ +glyphname = I.001; +lastChange = "2021-03-01 13:12:24 +0000"; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +paths = ( +{ +closed = 1; +nodes = ( +"185 0 LINE", +"415 0 LINE", +"415 700 LINE", +"185 700 LINE" +); +} +); +width = 600; +}, +{ +associatedMasterId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +layerId = "79A3A3AC-9288-47C2-855F-040FC78C65A0"; +name = "Color 1"; +paths = ( +{ +closed = 1; +nodes = ( +"415 0 LINE", +"540 -105 LINE", +"540 595 LINE", +"415 700 LINE" +); +} +); +width = 600; +}, +{ +associatedMasterId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +background = { +paths = ( +{ +closed = 1; +nodes = ( +"455 442 LINE", +"500 397 LINE", +"500 525 LINE", +"455 560 LINE" +); +}, +{ +closed = 1; +nodes = ( +"455 90 LINE", +"500 45 LINE", +"500 173 LINE", +"455 208 LINE" +); +} +); +}; +layerId = "DA3EBD73-82FA-4124-85DD-31E1E78E6FB1"; +name = "Color 2"; +paths = ( +{ +closed = 1; +nodes = ( +"455 40 LINE", +"500 -5 LINE", +"500 555 LINE", +"455 590 LINE" +); +} +); +width = 600; +}, +{ +associatedMasterId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +background = { +paths = ( +{ +closed = 1; +nodes = ( +"310 -105 LINE", +"540 -105 LINE", +"185 0 LINE" +); +} +); +}; +layerId = "71DB9149-5D1A-4B25-9EF3-E1BEC81311FA"; +name = "Color 2"; +paths = ( +{ +closed = 1; +nodes = ( +"310 -105 LINE", +"540 -105 LINE", +"415 0 LINE", +"185 0 LINE" +); +} +); +width = 600; +}, +{ +associatedMasterId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +background = { +paths = ( +{ +closed = 1; +nodes = ( +"348 133 LINE", +"413 133 LINE", +"377 162 LINE", +"312 162 LINE" +); +} +); +}; +layerId = "EF055C20-0F0F-4946-9658-118D85F4B36F"; +name = "Color 0"; +paths = ( +{ +closed = 1; +nodes = ( +"348 -67 LINE", +"413 -67 LINE", +"377 -38 LINE", +"312 -38 LINE" +); +} +); +width = 600; +}, +{ +associatedMasterId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +layerId = "FBB4A6BE-E06C-4CB3-BA24-527C837D6E11"; +name = "Color 0"; +paths = ( +{ +closed = 1; +nodes = ( +"185 0 LINE", +"415 0 LINE", +"415 700 LINE", +"185 700 LINE" +); +} +); +width = 600; +} +); +}, +{ +glyphname = a; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0061; +}, +{ +glyphname = b; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0062; +}, +{ +glyphname = c; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0063; +}, +{ +glyphname = d; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0064; +}, +{ +glyphname = e; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0065; +}, +{ +glyphname = f; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0066; +}, +{ +glyphname = g; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0067; +}, +{ +glyphname = h; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0068; +}, +{ +glyphname = i; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0069; +}, +{ +glyphname = j; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 006A; +}, +{ +glyphname = k; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 006B; +}, +{ +glyphname = l; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 006C; +}, +{ +glyphname = m; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 006D; +}, +{ +glyphname = n; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 006E; +}, +{ +glyphname = o; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 006F; +}, +{ +glyphname = p; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0070; +}, +{ +glyphname = q; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0071; +}, +{ +glyphname = r; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0072; +}, +{ +glyphname = s; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0073; +}, +{ +glyphname = t; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0074; +}, +{ +glyphname = u; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0075; +}, +{ +glyphname = v; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0076; +}, +{ +glyphname = w; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0077; +}, +{ +glyphname = x; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0078; +}, +{ +glyphname = y; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0079; +}, +{ +glyphname = z; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 007A; +}, +{ +glyphname = zero; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0030; +}, +{ +glyphname = one; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0031; +}, +{ +glyphname = two; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0032; +}, +{ +glyphname = three; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0033; +}, +{ +glyphname = four; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0034; +}, +{ +glyphname = five; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0035; +}, +{ +glyphname = six; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0036; +}, +{ +glyphname = seven; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0037; +}, +{ +glyphname = eight; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0038; +}, +{ +glyphname = nine; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0039; +}, +{ +glyphname = period; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 002E; +}, +{ +glyphname = comma; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 002C; +}, +{ +glyphname = hyphen; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 002D; +}, +{ +glyphname = space; +layers = ( +{ +layerId = "464B9E85-1346-425A-ABC6-448CE1D3DA6C"; +width = 600; +} +); +unicode = 0020; +} +); +instances = ( +{ +instanceInterpolations = { +"464B9E85-1346-425A-ABC6-448CE1D3DA6C" = 1; +}; +name = Regular; +} +); +unitsPerEm = 1000; +versionMajor = 1; +versionMinor = 0; +} From 1492cc20060501d7e7ae8b3e06f8e4a4e472bf5e Mon Sep 17 00:00:00 2001 From: Denis Moyogo Jacquerye Date: Mon, 1 Mar 2021 10:16:01 +0000 Subject: [PATCH 5/9] Store layerId and originalLayerName when necessary --- Lib/glyphsLib/builder/layers.py | 125 +++++++++++++++++++++++++------- 1 file changed, 99 insertions(+), 26 deletions(-) diff --git a/Lib/glyphsLib/builder/layers.py b/Lib/glyphsLib/builder/layers.py index c9bde74df..b1529c987 100644 --- a/Lib/glyphsLib/builder/layers.py +++ b/Lib/glyphsLib/builder/layers.py @@ -12,34 +12,71 @@ # See the License for the specific language governing permissions and # limitations under the License. +import re + from .constants import GLYPHS_PREFIX LAYER_ID_KEY = GLYPHS_PREFIX + "layerId" LAYER_ORDER_PREFIX = GLYPHS_PREFIX + "layerOrderInGlyph." LAYER_ORDER_TEMP_USER_DATA_KEY = "__layerOrder" +LAYER_ORIGINAL_NAME_KEY = GLYPHS_PREFIX + "layerOriginalName" +FOREGROUND_LAYER_ID_KEY = GLYPHS_PREFIX + "foregroundLayerId" def to_ufo_layer(self, glyph, layer): + layer_names_ids = { + (l.name, l.layerId) + for g in self.font.glyphs + for l in glyph.layers + if (l.associatedMasterId == layer.associatedMasterId) + } + layers_with_name = [name for name, _ in layer_names_ids if name == layer.name] + glyphs_layers = self.font.glyphs[glyph.name].layers ufo_font = self._sources[layer.associatedMasterId or layer.layerId].font + if layer.associatedMasterId == layer.layerId: ufo_layer = ufo_font.layers.defaultLayer elif layer.name not in ufo_font.layers: ufo_layer = ufo_font.newLayer(layer.name) - elif layer.name in ufo_font.layers and glyph.name in ufo_font.layers[layer.name]: - self.logger.warning( - f"{ufo_font.info.familyName} {ufo_font.info.styleName}: " - f"Glyph {glyph.name}, layer {layer.name}: Duplicate glyph layer name", + elif len(layers_with_name) > 1: + # If there's already a layer with the same layerId, use it. + # Otherwise make up a new layer with a new name. + layer_name = next( + ( + l.name + for l in ufo_font.layers + if l.lib.get(LAYER_ID_KEY) == layer.layerId + ), + None, ) - n = 1 - new_layer_name = layer.name - while new_layer_name in ufo_font.layers: - new_layer_name = f"{layer.name} #{n!r}" - n += 1 - ufo_layer = ufo_font.newLayer(new_layer_name) + if layer_name is not None: + ufo_layer = ufo_font.layers[layer_name] + else: + self.logger.warning( + f"{ufo_font.info.familyName} {ufo_font.info.styleName}: " + f"Glyph {glyph.name}, layer {layer.name}: Duplicate glyph layer name", + ) + n = 1 + new_layer_name = layer.name + while new_layer_name in ufo_font.layers: + new_layer_name = f"{layer.name} #{n!r}" + n += 1 + ufo_layer = ufo_font.newLayer(new_layer_name) + ufo_layer.lib[LAYER_ORIGINAL_NAME_KEY] = layer.name else: ufo_layer = ufo_font.layers[layer.name] - if self.minimize_glyphs_diffs: + + # Store layerId when other layers have the same name or when minimizing + # Glyphs diffs. + if len(layers_with_name) > 1 or self.minimize_glyphs_diffs: ufo_layer.lib[LAYER_ID_KEY] = layer.layerId + + # Store the layer order when color layers are present or when minimizing + # Glyphs diffs. + if ( + any([re.match(r"^Color \d+$", l.name) for l in glyphs_layers]) + or self.minimize_glyphs_diffs + ): ufo_layer.lib[LAYER_ORDER_PREFIX + glyph.name] = _layer_order_in_glyph( self, layer ) @@ -47,27 +84,41 @@ def to_ufo_layer(self, glyph, layer): def to_ufo_background_layer(self, glyph, layer): + layer_names_ids = { + (l.name, l.layerId) + for glyph in self.font.glyphs + for l in glyph.layers + if (l.associatedMasterId == layer.associatedMasterId) + } ufo_font = self._sources[layer.associatedMasterId or layer.layerId].font if layer.associatedMasterId == layer.layerId: layer_name = "public.background" else: layer_name = f"{layer.name}.background" + layers_with_name = [name for name, _ in layer_names_ids if name == layer.name] + if len(layers_with_name) > 1: + # Find foreground layer and use the same name as a base for the + # background layer name. + foreground_name = next( + ( + l.name + for l in ufo_font.layers + if l.lib.get(LAYER_ID_KEY) == layer.layerId + ), + None, + ) + assert foreground_name is not None + layer_name = f"{foreground_name}.background" + if layer_name not in ufo_font.layers: background_layer = ufo_font.newLayer(layer_name) - elif layer_name in ufo_font.layers and glyph.name in ufo_font.layers[layer_name]: - self.logger.warning( - f"{ufo_font.info.familyName} {ufo_font.info.styleName}: " - f"Glyph {glyph.name}, layer {layer_name}: Duplicate glyph layer name", - ) - n = 1 - new_layer_name = layer_name - while new_layer_name in ufo_font.layers: - new_layer_name = f"{layer.name} #{n!r}.background" - n += 1 - background_layer = ufo_font.newLayer(new_layer_name) else: background_layer = ufo_font.layers[layer_name] + + # Store foreground layerId when other foreground layers have the same name. + if len(layers_with_name) > 1: + background_layer.lib[FOREGROUND_LAYER_ID_KEY] = layer.layerId return background_layer @@ -87,13 +138,32 @@ def to_glyphs_layer(self, ufo_layer, glyph, master): layer = master_layer.background elif ufo_layer.name.endswith(".background"): # Find or create the foreground layer - # TODO: (jany) add lib attribute to find foreground by layer id - foreground_name = ufo_layer.name[: -len(".background")] + if FOREGROUND_LAYER_ID_KEY in ufo_layer.lib: + foreground_layerId = ufo_layer.lib[FOREGROUND_LAYER_ID_KEY] + foreground_layer = next( + ( + l + for l in self._sources[master.id].font.layers + if (l.lib.get(LAYER_ID_KEY) == foreground_layerId) + ), + None, + ) + assert foreground_layer is not None + foreground_name = foreground_layer.lib.get(LAYER_ORIGINAL_NAME_KEY) + else: + foreground_layerId = None + foreground_name = None + + if foreground_name is None: + foreground_name = ufo_layer.name[: -len(".background")] + foreground = next( ( l for l in glyph.layers - if l.name == foreground_name and l.associatedMasterId == master.id + if (foreground_layerId is None or foreground_layerId == l.layerId) + and l.name == foreground_name + and l.associatedMasterId == master.id ), None, ) @@ -117,7 +187,10 @@ def to_glyphs_layer(self, ufo_layer, glyph, master): layer.associatedMasterId = master.id if LAYER_ID_KEY in ufo_layer.lib: layer.layerId = ufo_layer.lib[LAYER_ID_KEY] - layer.name = ufo_layer.name + if LAYER_ORIGINAL_NAME_KEY in ufo_layer.lib: + layer.name = ufo_layer.lib[LAYER_ORIGINAL_NAME_KEY] + else: + layer.name = ufo_layer.name glyph.layers.append(layer) order_key = LAYER_ORDER_PREFIX + glyph.name if order_key in ufo_layer.lib: From c21674be17d7be2ad5d9c6501eb3f4f29446ce9f Mon Sep 17 00:00:00 2001 From: Denis Moyogo Jacquerye Date: Tue, 2 Mar 2021 04:51:31 +0000 Subject: [PATCH 6/9] Handle layers with same name once instead of in each glyph --- Lib/glyphsLib/builder/builders.py | 73 ++++++++++++++++++++++++++++-- Lib/glyphsLib/builder/constants.py | 4 ++ Lib/glyphsLib/builder/layers.py | 68 ++++++++-------------------- 3 files changed, 93 insertions(+), 52 deletions(-) diff --git a/Lib/glyphsLib/builder/builders.py b/Lib/glyphsLib/builder/builders.py index 74ec553af..b88e14f18 100644 --- a/Lib/glyphsLib/builder/builders.py +++ b/Lib/glyphsLib/builder/builders.py @@ -24,7 +24,14 @@ from fontTools import designspaceLib from glyphsLib import classes, util -from .constants import PUBLIC_PREFIX, FONT_CUSTOM_PARAM_PREFIX, GLYPHLIB_PREFIX +from .constants import ( + FONT_CUSTOM_PARAM_PREFIX, + FOREGROUND_LAYER_ID_KEY, + GLYPHLIB_PREFIX, + LAYER_ID_KEY, + LAYER_ORIGINAL_NAME_KEY, + PUBLIC_PREFIX, +) from .axes import WEIGHT_AXIS_DEF, WIDTH_AXIS_DEF, find_base_style, class_to_value GLYPH_ORDER_KEY = PUBLIC_PREFIX + "glyphOrder" @@ -180,8 +187,7 @@ def _is_vertical(self): @property def masters(self): - """Get an iterator over master UFOs that match the given family_name. - """ + """Get an iterator over master UFOs that match the given family_name.""" if self._sources: for source in self._sources.values(): yield source.font @@ -216,6 +222,10 @@ def masters(self): ufo_glyph = ufo_layer.newGlyph(glyph.name) self.to_ufo_glyph(ufo_glyph, layer, glyph) + # Prepare layers with the same name in Glyphs as layers UFO must have + # unique names. + self._prepare_layers_with_same_name_to_ufo() + # And sublayers (brace, bracket, ...) second. for glyph, layer in supplementary_layer_data: if ( @@ -517,6 +527,63 @@ def _copy_bracket_layers_to_ufo_glyphs(self, bracket_layer_map): # parent's kerning. _expand_kerning_to_brackets(glyph_name, ufo_glyph_name, ufo_font) + def _prepare_layers_with_same_name_to_ufo(self): + for master in self.font.masters: + ufo_font = self._sources[master.id].font + + # Collect layers in the order we first see them + layers_by_name = dict() + for glyph in self.font.glyphs: + for layer in glyph.layers: + if master.id == layer.associatedMasterId: + if layer.name not in layers_by_name: + layers_by_name[layer.name] = [] + layers_by_name[layer.name].append(layer) + + # Create layers that must have different names in UFO and + # store layerId and original layer name for foreground layers + # or foreground layerId for background layers. + for name, layers_with_name in layers_by_name.items(): + layerIds = {l.layerId for l in layers_with_name} + if len(layerIds) == 1: + continue + if BRACKET_LAYER_RE.match(name): + continue + + for layer in layers_with_name: + if layer.layerId == master.id: + continue + + layer_name = next( + ( + l.name + for l in ufo_font.layers + if l.lib.get(LAYER_ID_KEY) == layer.layerId + ), + None, + ) + + if layer_name is not None: + ufo_layer = ufo_font.layers[layer_name] + else: + n = 1 + layer_name = layer.name + while layer_name in ufo_font.layers: + layer_name = f"{layer.name} #{n!r}" + n += 1 + ufo_layer = ufo_font.newLayer(layer_name) + if layer.name != "Color 1": + ufo_layer.lib[LAYER_ORIGINAL_NAME_KEY] = layer.name + ufo_layer.lib[LAYER_ID_KEY] = layer.layerId + + if layer.hasBackground: + layer_name = f"{layer_name}.background" + if layer_name not in ufo_font.layers: + background_layer = ufo_font.newLayer(layer_name) + background_layer.lib[ + FOREGROUND_LAYER_ID_KEY + ] = layer.layerId + # Implementation is split into one file per feature from .anchors import to_ufo_propagate_font_anchors, to_ufo_glyph_anchors from .annotations import to_ufo_annotations diff --git a/Lib/glyphsLib/builder/constants.py b/Lib/glyphsLib/builder/constants.py index 83f5a960b..11debd84d 100644 --- a/Lib/glyphsLib/builder/constants.py +++ b/Lib/glyphsLib/builder/constants.py @@ -25,6 +25,10 @@ MASTER_CUSTOM_PARAM_PREFIX = GLYPHS_PREFIX + "customParameter.GSFontMaster." FONT_CUSTOM_PARAM_PREFIX = GLYPHS_PREFIX + "customParameter.GSFont." +LAYER_ID_KEY = GLYPHS_PREFIX + "layerId" +LAYER_ORIGINAL_NAME_KEY = GLYPHS_PREFIX + "layerOriginalName" +FOREGROUND_LAYER_ID_KEY = GLYPHS_PREFIX + "foregroundLayerId" + GLYPHS_COLORS = ( "0.85,0.26,0.06,1", "0.99,0.62,0.11,1", diff --git a/Lib/glyphsLib/builder/layers.py b/Lib/glyphsLib/builder/layers.py index b1529c987..98e2043d6 100644 --- a/Lib/glyphsLib/builder/layers.py +++ b/Lib/glyphsLib/builder/layers.py @@ -14,33 +14,26 @@ import re -from .constants import GLYPHS_PREFIX +from .constants import ( + FOREGROUND_LAYER_ID_KEY, + GLYPHS_PREFIX, + LAYER_ID_KEY, + LAYER_ORIGINAL_NAME_KEY, +) -LAYER_ID_KEY = GLYPHS_PREFIX + "layerId" LAYER_ORDER_PREFIX = GLYPHS_PREFIX + "layerOrderInGlyph." LAYER_ORDER_TEMP_USER_DATA_KEY = "__layerOrder" -LAYER_ORIGINAL_NAME_KEY = GLYPHS_PREFIX + "layerOriginalName" -FOREGROUND_LAYER_ID_KEY = GLYPHS_PREFIX + "foregroundLayerId" def to_ufo_layer(self, glyph, layer): - layer_names_ids = { - (l.name, l.layerId) - for g in self.font.glyphs - for l in glyph.layers - if (l.associatedMasterId == layer.associatedMasterId) - } - layers_with_name = [name for name, _ in layer_names_ids if name == layer.name] glyphs_layers = self.font.glyphs[glyph.name].layers ufo_font = self._sources[layer.associatedMasterId or layer.layerId].font if layer.associatedMasterId == layer.layerId: ufo_layer = ufo_font.layers.defaultLayer - elif layer.name not in ufo_font.layers: - ufo_layer = ufo_font.newLayer(layer.name) - elif len(layers_with_name) > 1: - # If there's already a layer with the same layerId, use it. - # Otherwise make up a new layer with a new name. + else: + # Find foreground layer and use the same name as a base for the + # background layer name. layer_name = next( ( l.name @@ -49,26 +42,14 @@ def to_ufo_layer(self, glyph, layer): ), None, ) - if layer_name is not None: - ufo_layer = ufo_font.layers[layer_name] + if layer_name is None and layer.name in ufo_font.layers: + ufo_layer = ufo_font.layers[layer.name] + elif layer_name is None: + ufo_layer = ufo_font.newLayer(layer.name) else: - self.logger.warning( - f"{ufo_font.info.familyName} {ufo_font.info.styleName}: " - f"Glyph {glyph.name}, layer {layer.name}: Duplicate glyph layer name", - ) - n = 1 - new_layer_name = layer.name - while new_layer_name in ufo_font.layers: - new_layer_name = f"{layer.name} #{n!r}" - n += 1 - ufo_layer = ufo_font.newLayer(new_layer_name) - ufo_layer.lib[LAYER_ORIGINAL_NAME_KEY] = layer.name - else: - ufo_layer = ufo_font.layers[layer.name] + ufo_layer = ufo_font.layers[layer_name] - # Store layerId when other layers have the same name or when minimizing - # Glyphs diffs. - if len(layers_with_name) > 1 or self.minimize_glyphs_diffs: + if LAYER_ID_KEY not in ufo_layer.lib and self.minimize_glyphs_diffs: ufo_layer.lib[LAYER_ID_KEY] = layer.layerId # Store the layer order when color layers are present or when minimizing @@ -84,20 +65,10 @@ def to_ufo_layer(self, glyph, layer): def to_ufo_background_layer(self, glyph, layer): - layer_names_ids = { - (l.name, l.layerId) - for glyph in self.font.glyphs - for l in glyph.layers - if (l.associatedMasterId == layer.associatedMasterId) - } ufo_font = self._sources[layer.associatedMasterId or layer.layerId].font if layer.associatedMasterId == layer.layerId: layer_name = "public.background" else: - layer_name = f"{layer.name}.background" - - layers_with_name = [name for name, _ in layer_names_ids if name == layer.name] - if len(layers_with_name) > 1: # Find foreground layer and use the same name as a base for the # background layer name. foreground_name = next( @@ -108,17 +79,16 @@ def to_ufo_background_layer(self, glyph, layer): ), None, ) - assert foreground_name is not None - layer_name = f"{foreground_name}.background" + if foreground_name is None: + layer_name = f"{layer.name}.background" + else: + layer_name = f"{foreground_name}.background" if layer_name not in ufo_font.layers: background_layer = ufo_font.newLayer(layer_name) else: background_layer = ufo_font.layers[layer_name] - # Store foreground layerId when other foreground layers have the same name. - if len(layers_with_name) > 1: - background_layer.lib[FOREGROUND_LAYER_ID_KEY] = layer.layerId return background_layer From 2fee768b6173143bd259e979f5280789dbf568ee Mon Sep 17 00:00:00 2001 From: Denis Moyogo Jacquerye Date: Tue, 2 Mar 2021 06:27:59 +0000 Subject: [PATCH 7/9] Find layerId associated with ufo_layer --- Lib/glyphsLib/builder/layers.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Lib/glyphsLib/builder/layers.py b/Lib/glyphsLib/builder/layers.py index 98e2043d6..842ad95e4 100644 --- a/Lib/glyphsLib/builder/layers.py +++ b/Lib/glyphsLib/builder/layers.py @@ -154,9 +154,23 @@ def to_glyphs_layer(self, ufo_layer, glyph, master): ) if layer is None: layer = self.glyphs_module.GSLayer() + layer.associatedMasterId = master.id if LAYER_ID_KEY in ufo_layer.lib: layer.layerId = ufo_layer.lib[LAYER_ID_KEY] + else: + # Try to find the layerId associated with the ufo_layer and use it + layerId = next( + ( + l.layerId + for g in self.font.glyphs + for l in g.layers + if l.name == ufo_layer.name and l.associatedMasterId == master.id + ), + None, + ) + if layerId: + layer.layerId = layerId if LAYER_ORIGINAL_NAME_KEY in ufo_layer.lib: layer.name = ufo_layer.lib[LAYER_ORIGINAL_NAME_KEY] else: From 67017f6123acd47ada0d9dafe1ebc0dcc7d58f82 Mon Sep 17 00:00:00 2001 From: Denis Moyogo Jacquerye Date: Tue, 2 Mar 2021 04:52:36 +0000 Subject: [PATCH 8/9] Update tests: no warning for duplicate layer name --- tests/builder/builder_test.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/builder/builder_test.py b/tests/builder/builder_test.py index 2c274ed14..4c54d27e9 100644 --- a/tests/builder/builder_test.py +++ b/tests/builder/builder_test.py @@ -861,13 +861,11 @@ def test_duplicate_supplementary_layers(self): sublayer.width = 0 sublayer.name = "SubLayer" glyph.layers.append(sublayer) - with CapturingLogHandler(builder.logger, level="WARNING") as captor: - ufo = self.to_ufos(font)[0] + ufo = self.to_ufos(font)[0] self.assertEqual( [l.name for l in ufo.layers], ["public.default", "SubLayer", "SubLayer #1"] ) - captor.assertRegex("Duplicate glyph layer name") def test_duplicate_supplementary_background_layers(self): """Test glyph background layers with same name.""" @@ -890,8 +888,7 @@ def test_duplicate_supplementary_background_layers(self): sublayer.name = "SubLayer" sublayer.background.width = 0 glyph.layers.append(sublayer) - with CapturingLogHandler(builder.logger, level="WARNING") as captor: - ufo = self.to_ufos(font)[0] + ufo = self.to_ufos(font)[0] self.assertEqual( [l.name for l in ufo.layers], @@ -903,7 +900,6 @@ def test_duplicate_supplementary_background_layers(self): "SubLayer #1.background", ], ) - captor.assertRegex("Duplicate glyph layer name") def test_color_layer_with_background(self): filename = os.path.join( From 5432f309f6fd9c5de16ff871a73a3cf0283de65b Mon Sep 17 00:00:00 2001 From: Denis Moyogo Jacquerye Date: Tue, 2 Mar 2021 05:04:26 +0000 Subject: [PATCH 9/9] BracketTestFont font name --- tests/data/BracketTestFont.glyphs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/data/BracketTestFont.glyphs b/tests/data/BracketTestFont.glyphs index 41e216201..86614f593 100644 --- a/tests/data/BracketTestFont.glyphs +++ b/tests/data/BracketTestFont.glyphs @@ -23,7 +23,7 @@ value = 1; } ); date = "2019-01-09 16:33:47 +0000"; -familyName = "New Font"; +familyName = BracketTestFont; fontMaster = ( { ascender = 800;