@@ -905,6 +905,83 @@ def test_duplicate_supplementary_background_layers(self):
905905 )
906906 captor .assertRegex ("Duplicate glyph layer name" )
907907
908+ def test_color_layer_with_background (self ):
909+ filename = os .path .join (
910+ os .path .dirname (__file__ ), ".." , "data" , "ColorColrCpalFont.glyphs"
911+ )
912+ with open (filename ) as f :
913+ font = glyphsLib .load (f )
914+ ufo = self .to_ufos (font , minimize_glyphs_diffs = False )[0 ]
915+
916+ glyph = font .glyphs ["I" ]
917+ assert {
918+ (
919+ l .name ,
920+ l .lib .get ("com.schriftgestaltung.layerId" ),
921+ l .lib .get ("com.schriftgestaltung.foregroundLayerId" ),
922+ )
923+ for l in ufo .layers
924+ } == {
925+ ("public.default" , None , None ),
926+ ("Color 0" , glyph .layers [1 ].layerId , None ),
927+ ("Color 1" , None , None ),
928+ ("Color 2" , glyph .layers [3 ].layerId , None ),
929+ ("Color 2.background" , None , glyph .layers [3 ].layerId ),
930+ ("Color 2 #1" , glyph .layers [4 ].layerId , None ),
931+ ("Color 2 #1.background" , None , glyph .layers [4 ].layerId ),
932+ ("Color 0 #1" , glyph .layers [5 ].layerId , None ),
933+ ("Color 0 #1.background" , None , glyph .layers [5 ].layerId ),
934+ }
935+ glyph = font .glyphs ["I.001" ]
936+ assert {
937+ (
938+ l .name ,
939+ l .lib .get ("com.schriftgestaltung.layerId" ),
940+ l .lib .get ("com.schriftgestaltung.foregroundLayerId" ),
941+ )
942+ for l in ufo .layers
943+ } == {
944+ ("public.default" , None , None ),
945+ ("Color 1" , None , None ),
946+ ("Color 2 #1" , glyph .layers [2 ].layerId , None ),
947+ ("Color 2 #1.background" , None , glyph .layers [2 ].layerId ),
948+ ("Color 2" , glyph .layers [3 ].layerId , None ),
949+ ("Color 2.background" , None , glyph .layers [3 ].layerId ),
950+ ("Color 0 #1" , glyph .layers [4 ].layerId , None ),
951+ ("Color 0 #1.background" , None , glyph .layers [4 ].layerId ),
952+ ("Color 0" , glyph .layers [5 ].layerId , None ),
953+ }
954+
955+ font = to_glyphs ((ufo ,))
956+ glyph = font .glyphs ["I" ]
957+ assert [l .name for l in glyph .layers ] == [
958+ "Regular" ,
959+ "Color 0" ,
960+ "Color 1" ,
961+ "Color 2" ,
962+ "Color 2" ,
963+ "Color 0" ,
964+ ]
965+ assert len (glyph .layers [1 ].background .paths ) == 0
966+ assert len (glyph .layers [2 ].background .paths ) == 0
967+ assert len (glyph .layers [3 ].background .paths ) == 1
968+ assert len (glyph .layers [4 ].background .paths ) == 2
969+ assert len (glyph .layers [5 ].background .paths ) == 1
970+ glyph = font .glyphs ["I.001" ]
971+ assert [l .name for l in glyph .layers ] == [
972+ "Regular" ,
973+ "Color 1" ,
974+ "Color 2" ,
975+ "Color 2" ,
976+ "Color 0" ,
977+ "Color 0" ,
978+ ]
979+ assert len (glyph .layers [1 ].background .paths ) == 0
980+ assert len (glyph .layers [2 ].background .paths ) == 2
981+ assert len (glyph .layers [3 ].background .paths ) == 1
982+ assert len (glyph .layers [4 ].background .paths ) == 1
983+ assert len (glyph .layers [5 ].background .paths ) == 0
984+
908985 def test_glyph_lib_Export (self ):
909986 font = generate_minimal_font ()
910987 glyph = add_glyph (font , "a" )
0 commit comments