Traceback when sorting AllFonts()



  • Hey,

    I was trying to sort the fonts in my AllFonts list.
    For this I turned to this page in the documentation. But when I try something like:

    fonts = AllFonts()
    fonts.sortBy('styleName')
    

    I get the following traceback.

    Traceback (most recent call last):
      File "lib/fontObjects/fontPartsWrappers.pyc", line 1955, in sortBy
      File "/Applications/RoboFont.app/Contents/Resources/lib/python3.6/ufo2fdk/fontInfoData.py", line 550, in getAttrWithFallback
    KeyError: 's'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "WhatIsGoingOn.py", line 2, in <module>
      File "lib/fontObjects/fontPartsWrappers.pyc", line 1957, in sortBy
      File "lib/fontObjects/fontPartsWrappers.pyc", line 1132, in __getattribute__
      File "/Applications/RoboFont.app/Contents/Resources/lib/python3.6/fontParts/base/info.py", line 82, in __getattribute__
    AttributeError: 'RInfo' object has no attribute 's'
    

    Is this not really implemented yet?
    Or should this be used differently?

    Thanks in advance!


  • admin

    This changed to a list of info attributes, see https://fontparts.readthedocs.io/en/stable/objects/



  • Ah, awesome.
    I got it to work now with fonts.sortBy(sortOptions=['openTypeOS2WeightClass','styleName']).
    Thanks for the quick reply.

    Sidenote: Isn’t it a bit confusing that the implementation of fontParts.world.FontList is called mojo.roboFont.FontsList?


  • admin

    @benedikt said in Traceback when sorting AllFonts():

    fontParts.world.FontList

    these functionalities should be provided by an implementation and not by fontParts, similar to CurrentFont, CurrentGlyph, CurrentLayer, CurrentContour, CurrentPoint,... FontList is optional but could be provided by an implementation.