SOLVED Find out what part of a glyph is selected

  • Hi, can someone suggest a better way of finding out what part of a glyph is selected, besides iterating through its parts?

    Right now, to find selected segments, I'm doing something like:

    selectedSegments = []
    for contour in glyph.contours:
       for segment in contour:
          if segment.selected:

    I've seen that the BaseEventTool object can return a selection object, but I haven't figured out a way to test if the object is a segment or not

    On a similar note, I'm not sure if some of the attributes/methods on this page just need to be updated, but RGlyph.selectedPoints gives me an AttributeError: 'RGlyph' object has no attribute 'selectedPoints'.


  • @frederik sorry, didn't realize it's new to FontParts too. I'll give 3.2b a try.

  • admin

    fontParts was fully implemented when 3.1 was released, only this api was added afterwards. This is present in the beta and in the upcoming release.

  • @gferreira ah, good to know that the selection API isn't fully implemented in 3.1. And yes—thanks for reminding me of comprehensions!

  • maybe worth adding: list comprehensions are handy for creating this kind of lists:

    g = CurrentGlyph()
    selectedSegments = [s for c in g for s in c if s.selected]
    selectedPoints   = [p for c in g for p in c.points if p.selected]

  • @jesentanadi the FontParts object selection API was introduced in RF 3.2 (currently in beta). I think you are running RF 3.1?

  • @frederik hi, thanks for confirming.

    I'm still getting an AttributeError: 'RGlyph' object has no attribute 'selectedPoints'​ when I use glyph.selectedPoints:

    0_1541186326170_Screen Shot 2018-11-02 at 3.17.45 PM.png

  • admin

    to find the selection points:

    glyph = CurrentGlyph()
    # on older RF
    # print(glyph.selection) # this is deprecated in favour of selectionPoints

    If you need a segment selection you will need to loop through all the contours and all the segments.

    glyph = CurrentGlyph()
    for contour in glyph:
        for segment in contour:

    hope this helps