-
Notifications
You must be signed in to change notification settings - Fork 73
Description
This is one of those issues where I’ve actually already found the problem, and it was solvable on my end. I’m not sure that this is something GFtools should necessarily fix, but I’m noting it here in case others hit the same problem and are searching for a solution. Also, though, this is potentially fixable in GFtools Builder, and I wouldn’t complain if this aspect of the project were improved.
Problem
When running a build with gftools builder config.yaml, with a config that included a designspace as a source, I was a bit stumped to get the following error:
gftools builder Familyname/config.yaml
Traceback (most recent call last):
File "/Users/stephennixon/venv/bin/gftools", line 8, in <module>
sys.exit(main())
^^^^^^
File "/Users/stephennixon/venv/lib/python3.12/site-packages/gftools/scripts/__init__.py", line 98, in main
mod.main(args[2:])
File "/Users/stephennixon/venv/lib/python3.12/site-packages/gftools/builder/__init__.py", line 445, in main
pd = GFBuilder(config, fontc_args=fontc_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/stephennixon/venv/lib/python3.12/site-packages/gftools/builder/__init__.py", line 78, in __init__
automatic_recipe = self.call_recipe_provider()
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/stephennixon/venv/lib/python3.12/site-packages/gftools/builder/__init__.py", line 109, in call_recipe_provider
return provider(self.config, self).write_recipe()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/stephennixon/venv/lib/python3.12/site-packages/gftools/builder/recipeproviders/googlefonts.py", line 104, in write_recipe
self.build_all_statics()
File "/Users/stephennixon/venv/lib/python3.12/site-packages/gftools/builder/recipeproviders/googlefonts.py", line 330, in build_all_statics
self.build_a_static(source, instance, output="ttf")
File "/Users/stephennixon/venv/lib/python3.12/site-packages/gftools/builder/recipeproviders/googlefonts.py", line 336, in build_a_static
target = self._static_filename(instance, suffix=suffix, extension=output)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/stephennixon/venv/lib/python3.12/site-packages/gftools/builder/recipeproviders/googlefonts.py", line 174, in _static_filename
instancebase = os.path.splitext(os.path.basename(instance.filename))[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen posixpath>", line 171, in basename
TypeError: expected str, bytes or os.PathLike object, not NoneTypeCause
The key is the second-to-last part of traceback, in instance.filename.
The designspace I was pointing to came from someone else, and they didn’t have filename attributes in the instances of their Designspace.
FontMake doesn’t require this attribute to build fonts, but it seems that the GFtools Builder does.
Solution
Set up instances with filename attributes. I went from this:
<instance familyname="Familyname" stylename="ExtraLight">
<location>
<dimension name="Weight" uservalue="200" />
</location>
</instance>...to this:
<instance name="Familyname ExtraLight" familyname="Familyname" stylename="ExtraLight" filename="../../../instances/Familyname-ExtraLight.ufo" postscriptfontname="Familyname-ExtraLight" stylemapfamilyname="Familyname ExtraLight" stylemapstylename="regular">
<location>
<dimension name="Weight" uservalue="200"/>
</location>
</instance>...and it now works without issue.
Comments
Hope this helps someone!
I’ll leave this open in case a maintainer decides to adjust this aspect, but I won’t be upset at all if this is closed as not planned. Again, I’m largely just filing this so that the solution is easy to find.
Thanks!