Skip to content

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

@otherjoel

Description

@otherjoel

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions