googlefonts / glyphsLib

A bridge from Glyphs source files (.glyphs) to UFOs
Apache License 2.0
178 stars 51 forks source link

There can be two color palette layers with the same color #1002

Open schriftgestalt opened 2 months ago

schriftgestalt commented 2 months ago

as seen in this example:

Bildschirmfoto 2024-04-27 um 19 52 03

Using glyphs2ufo produces this output:

Bad Color Bold: Glyph A, layer color.0: Duplicate glyph layer name
Bad Color Thin: Glyph A, layer color.0: Duplicate glyph layer name

and this layer mapping (it appends a '#' to make the name unique):

<key>com.github.googlei18n.ufo2ft.colorLayerMapping</key>
      <array>
        <array>
          <string>color.0</string>
          <integer>0</integer>
        </array>
        <array>
          <string>color.1</string>
          <integer>1</integer>
        </array>
        <array>
          <string>color.0 #1</string>
          <integer>0</integer>
        </array>
      </array>

So it is not sufficient to use GSLayer.name as layer names in the ufos.

khaledhosny commented 1 month ago

Do you have a test font?

schriftgestalt commented 1 month ago

https://github.com/googlefonts/glyphsLib/blob/Glyphs3-merge/tests/data/ColorComponents.glyphs

khaledhosny commented 1 month ago

The handling of color layers was supposed to be applied only when minimal=True (the thinking back then was that it is a ufo2ft-specefic feature so it was enabled only when minimal mode is enabled which is used when building UFOs with ufo2ft), but it seems that it is now partially applied when minimal=False:

$ glyphs2ufo ColorComponents.glyphs
Bad Color Bold: Glyph A, layer color.0: Duplicate glyph layer name
Bad Color Thin: Glyph A, layer color.0: Duplicate glyph layer name
Bad Color Thin: Glyph Aacute, layer color.0: Duplicate glyph layer name
Bad Color Bold: Glyph Aacute, layer color.0: Duplicate glyph layer name

And no warnings with:

$ glyphs2ufo --minimal ColorComponents.glyphs

I suggest we enable the handling of color layers unconditionally, since this seems to be a source of problems (e.g. https://github.com/googlefonts/gftools/issues/740).