question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`pyftsubset` gives missing glyphs exception when using single hyphens for CLI args

See original GitHub issue

The 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:open
  • Created 10 months ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
khaledhosnycommented, Nov 21, 2022

looks like options that has square brackets get treated as general text and use proportional font not monospaced one like the others.

0reactions
otherjoelcommented, Nov 21, 2022

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:

  1. Remove square brackets around optional values, e.g. change --gids=<NNN>[,<NNN>...] to --gids=<NNN>,<NNN>.... While the former is more correct, I think people would intuitively understand that multiple NNN is not required.
  2. Move any case of [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 to qe instead of the default qDe.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found