RoboFont › Forums › Help / General › g.copy
This topic contains 4 replies, has 2 voices, and was last updated by Thom 6 years ago.
- 
		AuthorPosts
- 
		
			
				
October 10, 2014 at 13:42 #5992Hi, 
 For some observers I need the decomposed, removeOverlaped glyph.
 I have sort of a solution by adding duplicate glyphs to the font and decompose, removeOverlap them. And automatically remove them when the observer was removed.
 But I know this can be done in a nicer way. But this code doesn’t do the trick. But way not? Seems okay to me…f = CurrentFont()g = f['H'] temp = g.copy() 
 temp.decompose()
 temp.removeOverlap()
 for c in temp.components:
 print c #these must be gone...
 drawGlyph(temp)<Component for I>
 <Component for I>
 Traceback (most recent call last):
 File "<untitled>", line 10, in <module>
 File "main.py", line 29, in drawGlyph
 File "lib/fontObjects/robofabWrapper.pyc", line 2736, in draw
 File "/Applications/RoboFont_Beta.app/Contents/Resources/lib/python2.7/defcon/objects/glyph.py", line 299, in draw
 File "/Applications/RoboFont_Beta.app/Contents/Resources/lib/python2.7/defcon/objects/glyph.py", line 308, in drawPoints
 File "/Applications/RoboFont_Beta.app/Contents/Resources/lib/python2.7/defcon/objects/component.py", line 107, in drawPoints
 File "/Applications/RoboFont_Beta.app/Contents/Resources/lib/python2.7/robofab/pens/adapterPens.py", line 111, in addComponent
 File "/Applications/RoboFont_Beta.app/Contents/Resources/lib/python2.7/fontTools/pens/basePen.py", line 166, in addComponent
 TypeError: 'NoneType' object has no attribute '__getitem__'Who can help? 
 Thanks! ThomOctober 10, 2014 at 13:53 #5993he A copy has no parent anymore… so it cannot find the referenced glyph in a component. So decompose will not work. Maybe the best option is to set the parent in the copied glyph: source = CurrentGlyph() g = source.copy() g.setParent(source.getParent()) October 10, 2014 at 14:06 #5996Hi, OK it draws. But still overlapped, and composed… October 13, 2014 at 15:45 #5997owke, this is idd not working cause a weakref object has to be referenced once or more. you could force it with: g = CurrentGlyph() copy = g.copy() # get the internal font and set it hard in the internal glyph object, even it is a copy copy.naked().setParent(g.naked().getParent()) copy.decompose() copy.removeOverlap() print copy.components October 13, 2014 at 15:56 #5998Great, this works! 
 Thanks!
- 
		AuthorPosts
You must be logged in to reply to this topic.