googlefonts / gftools

Misc tools for working with the Google Fonts library
Apache License 2.0
242 stars 71 forks source link

gen-stat raises "bad sfntVersion" #992

Closed guidoferreyra closed 2 months ago

guidoferreyra commented 2 months ago

When trying to patch STAT I get this issue. I’ve also seen this issue in fontbakery with some VF fonts built on glyphs. Any ideas?

This is the error log:

Traceback (most recent call last):
  File "/Users/guidoferreyra/fbenv/bin/gftools", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/guidoferreyra/fbenv/lib/python3.12/site-packages/gftools/scripts/__init__.py", line 98, in main
    mod.main(args[2:])
  File "/Users/guidoferreyra/fbenv/lib/python3.12/site-packages/gftools/scripts/gen_stat.py", line 66, in main
    fonts = [TTFont(f) for f in args.fonts]
             ^^^^^^^^^
  File "/Users/guidoferreyra/fbenv/lib/python3.12/site-packages/fontTools/ttLib/ttFont.py", line 174, in __init__
    self.reader = SFNTReader(file, checkChecksums, fontNumber=fontNumber)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/guidoferreyra/fbenv/lib/python3.12/site-packages/fontTools/ttLib/sfnt.py", line 85, in __init__
    raise TTLibError("Not a TrueType or OpenType font (bad sfntVersion)")
fontTools.ttLib.TTLibError: Not a TrueType or OpenType font (bad sfntVersion)

FWIW, this is how sfntVersion looks on the curren font

<ttFont sfntVersion="\x00\x01\x00\x00" ttLibVersion="4.50"> = 0x00010000

simoncozens commented 2 months ago

Something was in the command line which was not a font.

Did you say

gftools-gen-stat stat.yml myfont.ttf

instead of

gftools-gen-stat --src stat.yml my font.ttf

?

guidoferreyra commented 2 months ago

🤦 Thanks @simoncozens