IndexError: list index out of range (Solved)

Bruno Bruno's picture

Hi guys,

Just keep getting error messages after running the following code:


from robofab.world import CurrentFont

myFont = CurrentFont()

for myGlyph in myFont:
print myGlyph.name
myGlyph.autoContourOrder()
myGlyph.correctDirection()
myGlyph.update()
for myContours in myGlyph.contours:
myContours.autoStartSegment()

print "done now"

This is the error message:

Traceback (most recent call last):
File "", line 16, in ?
File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/RoboFab/robofab/objects/objectsBase.py", line 2129, in autoStartSegment
on = segment.onCurve
File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/RoboFab/robofab/objects/objectsBase.py", line 2330, in _get_onCurve
return self.points[-1]
File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/RoboFab/robofab/objects/objectsFL.py", line 1942, in _get_points
node = self._node
File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/RoboFab/robofab/objects/objectsFL.py", line 1880, in _get__node
return glyph.nodes[self._nodeIndex]
IndexError: list index out of range

The weird thing is (after running it a second time) it will not bump into the same problem again, but rather continues to the next problem, if that makes sense. After a while the script runs fine. Really have no clue here.

Thanks,

Bruno

Bruno Bruno's picture

Ok, for the interested:
Following should work, cheers


from robofab.world import CurrentFont

myFont = CurrentFont()
print myFont.info.postscriptFullName

myGlyph = myFont.keys

for myGlyph in myFont:
> print myGlyph.name
> myGlyph.autoContourOrder()
> myGlyph.correctDirection()
> > for myContours in myGlyph:
> > myContours.autoStartSegment()
> myGlyph.update()

print "done now"

Syndicate content Syndicate content