SOLVED 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.


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

  • 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
    # convert the tuple to a list
    components = list(components)
    # create a sorter
    def myComponentSorter(component):
        return component.baseGlyph
    # sort with our custom sort function
    # start a loop over our sorted components
    for component in components:
        # add all compenets
        g.appendComponent(component.baseGlyph, component.offset, component.scale)