Drawing components with drawbot

Hi there, how can I draw glyph’s components? (I couldn’t find the right code)
I have this (only draws bezier paths, not components):

from GlyphsApp import *

size(1000, 1000)
fill(0.4, 0.2)

myFont = Glyphs.font
for glyph in myFont.glyphs:
    newPage()
    fill(0, .4)
    for thisInstance in myFont.instances:
        instanceFont = thisInstance.interpolatedFontProxy
        instanceGlyph = instanceFont.glyphForName_(glyph.name)
        instanceLayer = instanceGlyph.layers[instanceFont.fontMasterID()]
        # the following line only draws bezier paths, not components
        drawPath(instanceLayer.bezierPath)

Many thanks as usual :slight_smile:

1 Like

For the NSBezierPath of a layer including its components, try:

Layer.completeBezierPath

… or step through each component’s bezierPath object:

for thisComponent in Layer.components:
	drawPath(thisComponent.bezierPath)
1 Like

Thanks @mekkablue, it worked like a charm!