googlefonts / pyfontaine

Python tool to check font files for language/character set support
https://github.com/googlefonts/pyfontaine
GNU General Public License v3.0
104 stars 20 forks source link

Make hyperglot.py ext safer #126

Open twardoch opened 3 years ago

twardoch commented 3 years ago

Fixes

$ pyfontaine --csv NotoSerifTamil-Regular.ttf
Traceback (most recent call last):
  File "/Users/adam/Library/Python/3.9/bin/pyfontaine", line 438, in <module>
    main()
  File "/Users/adam/Library/Python/3.9/bin/pyfontaine", line 242, in main
    sys.stdout.write(Builder.csv_(fonts))
  File "/Users/adam/Library/Python/3.9/lib/python/site-packages/fontaine/builder.py", line 320, in csv_
    for subset in _library.charsets:
  File "/Users/adam/Library/Python/3.9/lib/python/site-packages/fontaine/cmap.py", line 48, in charsets
    for charset_klass in module.Extension.get_charsets():
  File "/Users/adam/Library/Python/3.9/lib/python/site-packages/fontaine/ext/hyperglot.py", line 44, in __getcharsets__
    yield Extension.make_locale(key, locale, 0)
  File "/Users/adam/Library/Python/3.9/lib/python/site-packages/fontaine/ext/hyperglot.py", line 34, in make_locale
    dict(glyphs=Extension.to_charset(orthography),
  File "/Users/adam/Library/Python/3.9/lib/python/site-packages/fontaine/ext/hyperglot.py", line 24, in to_charset
    glyphs.extend(orthography.get("numerals", []))
AttributeError: 'str' object has no attribute 'extend'

and

Traceback (most recent call last):
  File "/Users/adam/Library/Python/3.9/bin/pyfontaine", line 438, in <module>
    main()
  File "/Users/adam/Library/Python/3.9/bin/pyfontaine", line 242, in main
    sys.stdout.write(Builder.csv_(fonts))
  File "/Users/adam/Library/Python/3.9/lib/python/site-packages/fontaine/builder.py", line 320, in csv_
    for subset in _library.charsets:
  File "/Users/adam/Library/Python/3.9/lib/python/site-packages/fontaine/cmap.py", line 48, in charsets
    for charset_klass in module.Extension.get_charsets():
  File "/Users/adam/Library/Python/3.9/lib/python/site-packages/fontaine/ext/hyperglot.py", line 49, in __getcharsets__
    for ix in range(0,len(locale["orthographies"])):
KeyError: 'orthographies'

and related fails.

davelab6 commented 3 years ago

@felipesanches PTAL

felipesanches commented 3 years ago

yep! That's good ;-)

felipesanches commented 3 years ago

but I think we need to fix this:

Screenshot from 2021-08-16 13-54-05 https://travis-ci.org/github/googlefonts/pyfontaine/builds/767725570