`pyftsubset` gives missing glyphs exception when using single hyphens for CLI args
See original GitHub issueThe docs seem to indicate that some arguments (such as the unicodes
argument, as well as glyphs
) should be given with one hyphen, and others with two hyphens.
I spent a couple of days trying to figure out why I was getting exceptions for missing glyphs, such as below:
❯ pyftsubset Courier\ Prime.ttf -glyphs='*' --verbose -layout-features='*' --flavor="woff2" --output-file="reg.woff2"
Text: ''
Unicodes: []
Glyphs: ['-glyphs=*', '-layout-features=*']
Gids: []
maxp pruned
cmap pruned
post pruned
name pruned
glyf pruned
Missing requested glyphs: {'-layout-features=*', '-glyphs=*'}
Traceback (most recent call last):
File "/opt/homebrew/bin/pyftsubset", line 8, in <module>
sys.exit(main())
File "/opt/homebrew/lib/python3.10/site-packages/fontTools/misc/loggingTools.py", line 372, in wrapper
return func(*args, **kwds)
File "/opt/homebrew/lib/python3.10/site-packages/fontTools/subset/__init__.py", line 3241, in main
subsetter.subset(font)
File "/opt/homebrew/lib/python3.10/site-packages/fontTools/subset/__init__.py", line 3047, in subset
self._closure_glyphs(font)
File "/opt/homebrew/lib/python3.10/site-packages/fontTools/subset/__init__.py", line 2855, in _closure_glyphs
raise self.MissingGlyphsSubsettingError(self.glyphs_missing)
fontTools.subset.Subsetter.MissingGlyphsSubsettingError: {'-layout-features=*', '-glyphs=*'}
I finally stumbled on the fix, which was to use two hyphens for all arguments (so, --glyphs
instead of -glyphs
), contra the docs.
Can/should the documentation be updated to reflect this? I’ve been out of Python for a while, so I don’t know if there is some historical reason why some options were documented this way.
I’m using Python 3.10 under ZSH on Mac OS 12.6 (Monterey) on ARM64.
Issue Analytics
- State:
- Created 10 months ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Issues · fonttools/fonttools - GitHub
#2907 opened last month by moi15moi. pyftsubset gives missing glyphs exception when using single hyphens for CLI args. #2900 opened last month by...
Read more >subset — fontTools Documentation - Read the Docs
pyftsubset is an OpenType font subsetter and optimizer, based on fontTools. ... Args: font-file. The input font file. glyph. Specify one or more...
Read more >for single-character options, but double dashes `--` for words?
If I read a double dash, --, then the rest of the command line argument must match a single option. I would say...
Read more >How to use pyftsubset of Fonttools inside of the python ...
pyftsubset is itself just a Python script, which calls fontTools.subset.main , which in turn parses sys.argv (command-line args) to perform ...
Read more >Python Command Line Arguments
Thanks to the wildcards expansion feature of the Unix terminal, it's also possible to provide Python command line arguments with wildcard characters. One...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
looks like options that has square brackets get treated as general text and use proportional font not monospaced one like the others.
Yes, it feels like the square brackets are breaking a regex somewhere.
Quickest fix, then, would be to make some simple edits to the docstring:
--gids=<NNN>[,<NNN>...]
to--gids=<NNN>,<NNN>...
. While the former is more correct, I think people would intuitively understand that multipleNNN
is not required.[default]
that occurs directly after the option to the end of its description instead (example:--ignore-missing-unicodes
). Other options already use this convention, so this would make everything more consistent anyway.I squinted at the RST syntax for option lists but am still not sure if there is a more idiomatic method for showing optional values in RST.
Another approach would be to disable “smart” processing for dashes altogether by setting the
smartquotes_action
option toqe
instead of the defaultqDe
.