Change Component Indexes



  • Hi there!

    Is there a way to change a glyph's component indexes via a script? I feel like I might be totally overthinking this problem.

    Best,
    Connor


  • admin

    he Connor

    there are several ways to achieve a different sorting for components: this is an easy one. You can also make a pen to sort the components.

    good luck

    # get current glyph
    g = CurrentGlyph()
    # get all components
    components = g.components
    # clear them all
    g.clearComponents()
    # convert the tuple to a list
    components = list(components)
    # create a sorter
    def myComponentSorter(component):
        return component.baseGlyph
    # sort with our custom sort function
    components.sort(key=myComponentSorter)
    # start a loop over our sorted components
    for component in components:
        # add all compenets
        g.appendComponent(component.baseGlyph, component.offset, component.scale)
    


  • Wow, thank you * 10000 for the help, Frederik! I really appreciate it.


Log in to reply
 

Looks like your connection to RoboFont ● Forum was lost, please wait while we try to reconnect.