SOLVED RGlyph.area method only works on glyphs with contours.
bahman last edited by gferreira
Is it possible to add the ability to make
RGlyph.areato work on glyphs which have components? Right now it only works on glyphs which have contours, but on glyphs with components it gives this error:
File "/Applications/RoboFont.app/Contents/Resources/lib/python3.7/fontParts/base/base.py", line 90, in __get__ File "/Applications/RoboFont.app/Contents/Resources/lib/python3.7/fontParts/fontshell/glyph.py", line 106, in _get_area File "/Applications/RoboFont.app/Contents/Resources/lib/python3.7/defcon/objects/glyph.py", line 278, in _get_area File "/Applications/RoboFont.app/Contents/Resources/lib/python3.7/defcon/objects/base.py", line 313, in getRepresentation File "/Applications/RoboFont.app/Contents/Resources/lib/python3.7/defcon/tools/representations.py", line 44, in glyphAreaRepresentationFactory File "/Applications/RoboFont.app/Contents/Resources/lib/python3.7/defcon/objects/glyph.py", line 479, in draw File "/Applications/RoboFont.app/Contents/Resources/lib/python3.7/defcon/objects/glyph.py", line 491, in drawPoints File "/Applications/RoboFont.app/Contents/Resources/lib/python3.7/defcon/objects/component.py", line 185, in drawPoints File "/Applications/RoboFont.app/Contents/Resources/lib/python3.7/fontTools/pens/pointPen.py", line 222, in addComponent File "/Applications/RoboFont.app/Contents/Resources/lib/python3.7/fontTools/pens/basePen.py", line 176, in addComponent TypeError: 'NoneType' object is not subscriptable
gferreira last edited by
I agree it would be nice if it just worked with components too. not sure at which level to add it though:
in the meantime, you can get it to work using the DecomposePointPen:
from mojo.pens import DecomposePointPen g = CurrentGlyph() g2 = RGlyph() g.drawPoints(DecomposePointPen(g.font, g2.getPointPen())) print(g2.area)
no glyphset is provided in defcon see https://github.com/robotools/defcon/blob/master/Lib/defcon/tools/representations.py#L43
a fix will follow shortly
follow up here: https://github.com/robotools/defcon/pull/272
bahman last edited by
Thanks Gustavo, this is the solution I used too in the meanwhile.
Looking forward to get the update!