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

Traceback with nested “UFO Filename” custom parameter #968

Open
frankrolf opened this issue Dec 18, 2023 · 0 comments
Open

Traceback with nested “UFO Filename” custom parameter #968

frankrolf opened this issue Dec 18, 2023 · 0 comments

Comments

@frankrolf
Copy link

frankrolf commented Dec 18, 2023

I have a .glyphs source, in which the UFO Filename custom parameter is nested, like this:

name = "UFO Filename";
value = "master_0/Dummy-Roman_6ptRg.ufo";

This setup causes a Traceback:

Traceback (most recent call last):
  File "bin/glyphs2ufo", line 8, in <module>
    sys.exit(_glyphs2ufo_entry_point())
  File "lib/python3.10/site-packages/glyphsLib/cli.py", line 276, in _glyphs2ufo_entry_point
    return main(args)
  File "lib/python3.10/site-packages/glyphsLib/cli.py", line 234, in main
    return options.func(options)
  File "lib/python3.10/site-packages/glyphsLib/cli.py", line 253, in glyphs2ufo
    glyphsLib.build_masters(
  File "lib/python3.10/site-packages/glyphsLib/__init__.py", line 152, in build_masters
    source.font.save(ufo_path)
  File "lib/python3.10/site-packages/ufoLib2/objects/font.py", line 592, in save
    with UFOWriter(path, structure=structure, validate=validate) as writer:
  File "lib/python3.10/site-packages/fontTools/ufoLib/__init__.py", line 948, in __init__
    raise UFOLibError(
fontTools.ufoLib.errors.UFOLibError: Cannot write to 'master_0/Dummy-Roman_6ptRg.ufo': directory does not exist

I don’t know how you’d prefer to solve this, but I did this quick-and-dirty fix just before https://github.com/googlefonts/glyphsLib/blob/main/Lib/glyphsLib/__init__.py#L151:

        ufo_path = os.path.join(master_dir, source.filename)
        clean_ufo(ufo_path)
        # nested dir:
        ufo_subdirs = os.path.dirname(ufo_path)
        if not os.path.exists(ufo_subdirs):
            os.makedirs(ufo_subdirs)
        source.font.save(ufo_path)

Possibly brittle, but fixes the problem on my end.

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

1 participant