RoboFont crashing on UFO – GlifLibError: line can not have an offcurve.



  • I'm trying to open a UFO, but RoboFont crashes each time. This may be caused by merging different versions of a glyph with Git.

    The error I'm getting in the RF log is:

    GlifLibError: line can not have an offcurve.

    So, it seems that I have a corrupted outline somewhere, but it's unclear where, exactly.

    I can revert a glyph or glyphs to an earlier version if it is causing the problem, but I'd rather not revert everything, as there are quite a few changed glyphs in the branch I'm merging, and that would potentially lose a fair bit of work just to avoid an issue that might be really small.

    Is there a way that I could find which glyph is failing to open? For instance, is there some way a fontTools script could go through glyphs, printing each name before attempting to open it?

    I'll report back if I figure this out on my own, but if anyone has any insights, that would be amazing!

    09/08/2019 09:43:46 >   OUTPUT > ROBOFONT >> Traceback (most recent call last):
    09/08/2019 09:43:46 >   OUTPUT > ROBOFONT >> File "lib/UI/fontOverView/doodleGlyphCollectionView.pyc", line 752, in drawRect_
    09/08/2019 09:43:46 >   OUTPUT > ROBOFONT >> File "/Applications/RoboFont3.3b.app/Contents/Resources/lib/python3.6/defconAppKit/controls/glyphCellView.py", line 509, in drawRect_
    09/08/2019 09:43:46 >   OUTPUT > ROBOFONT >> glyph = self.getGlyph_(glyphName)
    09/08/2019 09:43:46 >   OUTPUT > ROBOFONT >> File "lib/UI/fontOverView/doodleGlyphCollectionView.pyc", line 717, in getGlyph_
    09/08/2019 09:43:46 >   OUTPUT > ROBOFONT >> File "/Applications/RoboFont3.3b.app/Contents/Resources/lib/python3.6/defcon/objects/font.py", line 228, in __getitem__
    09/08/2019 09:43:46 >   OUTPUT > ROBOFONT >> return self._glyphSet[name]
    09/08/2019 09:43:46 >   OUTPUT > ROBOFONT >> File "/Applications/RoboFont3.3b.app/Contents/Resources/lib/python3.6/defcon/objects/layer.py", line 248, in __getitem__
    09/08/2019 09:43:46 >   OUTPUT > ROBOFONT >> self.loadGlyph(name)
    09/08/2019 09:43:46 >   OUTPUT > ROBOFONT >> File "lib/fontObjects/doodleLayer.pyc", line 58, in loadGlyph
    09/08/2019 09:43:46 >   OUTPUT > ROBOFONT >> File "/Applications/RoboFont3.3b.app/Contents/Resources/lib/python3.6/defcon/objects/layer.py", line 173, in loadGlyph
    09/08/2019 09:43:46 >   OUTPUT > ROBOFONT >> self._glyphSet.readGlyph(glyphName=name, glyphObject=glyph, pointPen=pointPen)
    09/08/2019 09:43:46 >   OUTPUT > ROBOFONT >> File "/Applications/RoboFont3.3b.app/Contents/Resources/lib/python3.6/fontTools/ufoLib/glifLib.py", line 355, in readGlyph
    09/08/2019 09:43:46 >   OUTPUT > ROBOFONT >> _readGlyphFromTree(tree, glyphObject, pointPen, formatVersions=formatVersions, validate=validate)
    09/08/2019 09:43:46 >   OUTPUT > ROBOFONT >> File "/Applications/RoboFont3.3b.app/Contents/Resources/lib/python3.6/fontTools/ufoLib/glifLib.py", line 896, in _readGlyphFromTree
    09/08/2019 09:43:46 >   OUTPUT > ROBOFONT >> _readGlyphFromTreeFormat2(tree=tree, glyphObject=glyphObject, pointPen=pointPen, validate=validate)
    09/08/2019 09:43:46 >   OUTPUT > ROBOFONT >> File "/Applications/RoboFont3.3b.app/Contents/Resources/lib/python3.6/fontTools/ufoLib/glifLib.py", line 969, in _readGlyphFromTreeFormat2
    09/08/2019 09:43:46 >   OUTPUT > ROBOFONT >> buildOutlineFormat2(glyphObject, pointPen, element, identifiers, validate)
    09/08/2019 09:43:46 >   OUTPUT > ROBOFONT >> File "/Applications/RoboFont3.3b.app/Contents/Resources/lib/python3.6/fontTools/ufoLib/glifLib.py", line 1169, in buildOutlineFormat2
    09/08/2019 09:43:46 >   OUTPUT > ROBOFONT >> _buildOutlineContourFormat2(pen, element, identifiers, validate)
    09/08/2019 09:43:46 >   OUTPUT > ROBOFONT >> File "/Applications/RoboFont3.3b.app/Contents/Resources/lib/python3.6/fontTools/ufoLib/glifLib.py", line 1194, in _buildOutlineContourFormat2
    09/08/2019 09:43:46 >   OUTPUT > ROBOFONT >> massaged = _validateAndMassagePointStructures(contour, pointAttributesFormat2, validate=validate)
    09/08/2019 09:43:46 >   OUTPUT > ROBOFONT >> File "/Applications/RoboFont3.3b.app/Contents/Resources/lib/python3.6/fontTools/ufoLib/glifLib.py", line 1336, in _validateAndMassagePointStructures
    09/08/2019 09:43:46 >   OUTPUT > ROBOFONT >> raise GlifLibError("line can not have an offcurve.")
    09/08/2019 09:43:46 >   OUTPUT > ROBOFONT >> fontTools.ufoLib.errors
    09/08/2019 09:43:46 >   OUTPUT > ROBOFONT >> .
    09/08/2019 09:43:46 >   OUTPUT > ROBOFONT >> GlifLibError
    09/08/2019 09:43:46 >   OUTPUT > ROBOFONT >> :
    09/08/2019 09:43:46 >   OUTPUT > ROBOFONT >> line can not have an offcurve.
    


  • Anthrotype helped me find the issue on on the FontTools repo:

    https://github.com/fonttools/fonttools/issues/1688

    from fontTools.ufoLib.glifLib import GlifLibError
    from defcon import Font
    
    ufo = Font("YourFont.ufo")
    for layer in ufo.layers: 
        for glyphName in layer.keys(): 
            try: 
                layer[glyphName] 
            except GlifLibError: 
                print(layer.name, glyphName)