robotools / compositor

A basic OpenType GSUB and GPOS layout engine.
MIT License
30 stars 11 forks source link

Loading font: AttributeError: Coverage #19

Closed yanone closed 7 years ago

yanone commented 7 years ago

Hi Tal,

I can't load an OTF font with compositor using the latest version of fontTools. Sounds familiar? Are they compatible? Thanks in advance.

Here's the traceback:


>>> font = compositor.Font('/Users/yanone/Schriften/Font Produktion/Fonts/NonameSans-Regular.otf')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/yanone/Code/svn/typesupply/compositor.git/Lib/compositor/font.py", line 22, in __init__
    self.loadFeatures()
  File "/Users/yanone/Code/svn/typesupply/compositor.git/Lib/compositor/font.py", line 117, in loadFeatures
    self.setFeatureTables(gdef, gsub, gpos)
  File "/Users/yanone/Code/svn/typesupply/compositor.git/Lib/compositor/layoutEngine.py", line 37, in setFeatureTables
    self.gsub = GSUB().loadFromFontTools(gsub, self.reversedCMAP, self.gdef)
  File "/Users/yanone/Code/svn/typesupply/compositor.git/Lib/compositor/tables.py", line 67, in loadFromFontTools
    self.LookupList = self._LookupListClass().loadFromFontTools(table.table.LookupList, gdef)
  File "/Users/yanone/Code/svn/typesupply/compositor.git/Lib/compositor/lookupList.py", line 27, in loadFromFontTools
    self.Lookup = [self._LookupClass().loadFromFontTools(lookup, self, gdef) for lookup in lookupList.Lookup]
  File "/Users/yanone/Code/svn/typesupply/compositor.git/Lib/compositor/lookupList.py", line 58, in loadFromFontTools
    obj = cls().loadFromFontTools(subtable, self)
  File "/Users/yanone/Code/svn/typesupply/compositor.git/Lib/compositor/subTablesGSUB.py", line 101, in loadFromFontTools
    self.Coverage = Coverage().loadFromFontTools(subtable.Coverage)
  File "/Library/Python/2.7/site-packages/fonttools-3.6.3.dev0-py2.7.egg/fontTools/ttLib/tables/otBase.py", line 539, in __getattr__
    raise AttributeError(attr)
AttributeError: Coverage
yanone commented 7 years ago

Okay, I understand there have been many changes to fontTools. I tried using the old 2.4 version but it also fails for a different reason. What is the last fontTools version known to you to work with compositor? Can you tell? I wouldn't mind hard-wiring an older version of fontTools for this particular task.

anthrotype commented 7 years ago

The API for MultipleSubst GSUB LookupType 2 was changed in fonttools 3.1.

See commit 1356a67 (from 10 September 2015) and the discussion at https://github.com/fonttools/fonttools/issues/355

Compositor should be updated to use the new simplified API for MultipleSubst.

In the meantime, you could try using fonttools 3.0 which has the old API.

anthrotype commented 7 years ago

@yanone if you pull the latest compositor master, it should now work with more recent fonttools. Please re-open if that's not the case, thanks.

yanone commented 7 years ago

So awesome. Thank you so much!