Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Layer with alternate and intermiate attributes throws an error #1050

Open
khaledhosny opened this issue Nov 27, 2024 · 2 comments
Open

Layer with alternate and intermiate attributes throws an error #1050

khaledhosny opened this issue Nov 27, 2024 · 2 comments

Comments

@khaledhosny
Copy link
Collaborator

I have a virtual master that goes from 0 to 100 to make some glyphs wider. Some of these glyphs the narrow and the wider form are incompatible, so I need to use an alternate layer. See for for background.

I have the following layer setup:

Image

It works in Glyphs, but with fontmake I get the following glyphsLib error:

INFO:fontmake.font_project:Building master UFOs and designspace from Glyphs source
INFO:glyphsLib.parser:Parsing .glyphs file
INFO:glyphsLib.builder:Running 'propagate_all_anchors' transformation
Traceback (most recent call last):
  File "/venv/bin/fontmake", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/venv/lib/python3.12/site-packages/fontmake/__main__.py", line 708, in main
    project.run_from_glyphs(inputs.glyphs_path, **args)
  File "/venv/lib/python3.12/site-packages/fontmake/font_project.py", line 910, in run_from_glyphs
    designspace = self.build_master_ufos(
                  ^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.12/site-packages/fontTools/misc/loggingTools.py", line 375, in wrapper
    return func(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.12/site-packages/fontmake/font_project.py", line 246, in build_master_ufos
    designspace = glyphsLib.to_designspace(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.12/site-packages/glyphsLib/builder/__init__.py", line 161, in to_designspace
    return builder.designspace
           ^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.12/site-packages/glyphsLib/builder/builders.py", line 344, in designspace
    self.to_designspace_bracket_layers()  # .bracket_layers
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.12/site-packages/glyphsLib/builder/bracket_layers.py", line 67, in to_designspace_bracket_layers
    copy_bracket_layers_to_ufo_glyphs(self, bracket_layer_map)
  File "/venv/lib/python3.12/site-packages/glyphsLib/builder/bracket_layers.py", line 108, in copy_bracket_layers_to_ufo_glyphs
    ufo_glyph = ufo_layer.newGlyph(ufo_glyph_name)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.12/site-packages/ufoLib2/objects/layer.py", line 336, in newGlyph
    raise KeyError(f"glyph named '{name}' already exists")
KeyError: "glyph named 'behDotless_alef-ar.BRACKET.varAlt01' already exists"

Test file:
TestVirtualMasterAlternateLayer.zip

@schriftgestalt
Copy link
Collaborator

I had a look at the code. It differentiates too much between brace and bracket layers. I might be better to decompose bracket layers on the GSFont side. That way the to_ufo part will be much simpler and could handle such cases much better (there can be color bracket layers and such …).

schriftgestalt added a commit that referenced this issue Nov 27, 2024
@schriftgestalt
Copy link
Collaborator

schriftgestalt commented Nov 27, 2024

I found a reasonable (I hope) fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants