def to_ufo_components(self, ufo_glyph, layer):
    """Draw .glyphs components onto a pen, adding them to the parent glyph."""
    pen = ufo_glyph.getPointPen()

    for index, component in enumerate(layer.components):
        pen.addComponent(component.name, component.transform)

        if component.anchor:
            if COMPONENT_INFO_KEY not in ufo_glyph.lib:
                ufo_glyph.lib[COMPONENT_INFO_KEY] = []
            ufo_glyph.lib[COMPONENT_INFO_KEY].append(
                {"name": component.name, "index": index, "anchor": component.anchor}
            )

    # data related to components stored in lists of booleans
    # each list's elements correspond to the components in order
    for key in ["alignment", "locked", "smartComponentValues"]:
        values = [getattr(c, key) for c in layer.components]
        if any(values):
            ufo_glyph.lib[_lib_key(key)] = values
def to_ufo_components ( self , ufo_glyph , layer ) : pen = ufo_glyph . getPointPen ( ) for index , component in enumerate ( layer . components ) : pen . addComponent ( component . name , component . transform ) if component . anchor : if COMPONENT_INFO_KEY not in ufo_glyph . lib : ufo_glyph . lib [ COMPONENT_INFO_KEY ] = [ ] ufo_glyph . lib [ COMPONENT_INFO_KEY ] . append ( { "name" : component . name , "index" : index , "anchor" : component . anchor } ) for key in [ "alignment" , "locked" , "smartComponentValues" ] : values = [ getattr ( c , key ) for c in layer . components ] if any ( values ) : ufo_glyph . lib [ _lib_key ( key ) ] = values
Draw .glyphs components onto a pen, adding them to the parent glyph.