adobe-type-tools / afdko

Adobe Font Development Kit for OpenType
https://adobe-type-tools.github.io/afdko/
Other
1.06k stars 167 forks source link

Fix otfstemhist bugs #1703

Closed skef closed 1 year ago

skef commented 1 year ago

1697 barfs w/o any arguments

1699 cannot specify glyphs by GID

1700 cannot specify glyphs via external glyph list

1701 -h reports wrong tool name

Description

Fixes the listed bugs. Some notes:

  1. We fix the hyphen problem by looking for the token in the glyph list, if we find it we treat it like a simple name rather than a range.
  2. I left the convention where you can specify a glyph range with normal names rather than GIDs or CID names, because it seems harmless and potentially useful after the other fixes

Some of this could be improved further (like the glyph list file format) but given how long its been broken, maybe this level is sufficient.

Checklist:

Closes #1697 Closes #1699 Closes #1700 Closes #1701

frankrolf commented 1 year ago

1697 (barf), #1698 (dashes), #1699 (GID) and #1701 (help file content) confirmed fixed.

When testing for #1700, I did make a file in “one glyph per line” format at first (which seems more natural to me) – the result is

WARNING: glyph name <koKai> in range koKai-thai
khoKhai from glyph selection list option is not in font <xxx Traditional-Regular>.
Traceback (most recent call last):
  File "/Users/fg/.pyenv/versions/3.10.13/bin/otfstemhist", line 8, in <module>
    sys.exit(stemhist())
  File "/Users/fg/.pyenv/versions/3.10.13/lib/python3.10/site-packages/afdko/otfautohint/__main__.py", line 944, in stemhist
    hintFiles(options)
  File "/Users/fg/.pyenv/versions/3.10.13/lib/python3.10/site-packages/afdko/otfautohint/autohint.py", line 457, in hintFiles
    fw = fontWrapper(options, [fi])
  File "/Users/fg/.pyenv/versions/3.10.13/lib/python3.10/site-packages/afdko/otfautohint/autohint.py", line 232, in __init__
    raise FontParseError("Selected glyph list is empty for " +
afdko.otfautohint.FontParseError: Selected glyph list is empty for font <xxx Traditional-Regular>.
source_1 (master✗) $ otfstemhist --traceback --glyphs-file ~/Desktop/glyph_names.txt AdobeCleanThaiLooped-Medium.ufo

When converting those glyph names to a single, comma-separated line, everything works.