googlefonts / pyfontaine

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

NotImplementedError: Get glyph names is not implemented with FreeType library #83

Open davelab6 opened 8 years ago

davelab6 commented 8 years ago

Using the latest git master head, and the latest release, I can no longer run pyfontaine :(

$ pyfontaine font.ttf 
WARNING: Please install PyICU <https://pypi.python.org/pypi/PyICU> to enable CLDR related features, perhaps with: pip install pyicu
Traceback (most recent call last):
  File "/usr/local/bin/pyfontaine", line 4, in <module>
    __import__('pkg_resources').run_script('fontaine==1.3.9', 'pyfontaine')
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 735, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1652, in run_script
    exec(code, namespace, namespace)
  File "/usr/local/lib/python2.7/site-packages/fontaine-1.3.9-py2.7.egg/EGG-INFO/scripts/pyfontaine", line 448, in <module>
    main()
  File "/usr/local/lib/python2.7/site-packages/fontaine-1.3.9-py2.7.egg/EGG-INFO/scripts/pyfontaine", line 343, in main
    tree = director.construct_tree(fonts)
  File "/usr/local/lib/python2.7/site-packages/fontaine-1.3.9-py2.7.egg/fontaine/builder.py", line 145, in construct_tree
    for charsetinfo in font.get_orthographies(self.library):
  File "/usr/local/lib/python2.7/site-packages/fontaine-1.3.9-py2.7.egg/fontaine/font.py", line 262, in get_orthographies
    yield CharsetInfo(self, result)
  File "/usr/local/lib/python2.7/site-packages/fontaine-1.3.9-py2.7.egg/fontaine/font.py", line 149, in __init__
    self.init_configuration_for_glyphnames()
  File "/usr/local/lib/python2.7/site-packages/fontaine-1.3.9-py2.7.egg/fontaine/font.py", line 163, in init_configuration_for_glyphnames
    if set(glyphs) & set(self.ttfont.getGlyphNames()):
  File "/usr/local/lib/python2.7/site-packages/fontaine-1.3.9-py2.7.egg/fontaine/font.py", line 395, in getGlyphNames
    raise NotImplementedError(('Get glyph names is not implemented'
NotImplementedError: Get glyph names is not implemented with FreeType library
davelab6 commented 8 years ago

@vitalyvolkov I committed a workaround to this, please could you push the version bump to pypi :)

davelab6 commented 8 years ago

Was my hack ok? It seems that the freetype library was used instead of fontTools for speed, but ft can only access a subset of what fontTools can access - and glyph names are outside the subset.

I guess that the way it should work in 'ft' mode is to subclass/override the fontTools methods that it can return faster, but use fontTools when needed.