Highlighting glyphs in the font window



  • I'm looking for a way to highlight or mark some glyphs in the font window via a script, but without changing the save state of the glyphs. At the moment I'm changing the RGlyph.mark attribute, but that makes the affected glyph being "unsaved".

    An overlay graphic (like the small "L" for layers) would also be a solution, but I have no idea how to add something like that.

    Perhaps I should rather generate smart sets via script to group the glyphs I want ...

    Any ideas or suggestions?


  • admin

    The mark color is saved in the lib and is actually changing the font data, so it makes sense that the save state of the document will update.

    There are some options:

    set the change count of the document to zero after changing the font data, just be careful with data loss, of unsaved fonts

    from AppKit import NSChangeCleared
    
    font = CurrentFont()
    
    for glyphName in font.selection + font.templateSelection:
        glyph = font[glyphName]
        glyph.mark = (1, 0, 0, 1)
    
    document = font.document()
    if document:
        # set the document change count to zero
        document.updateChangeCount_(NSChangeCleared)
    

    Adding an L or N (for glyph.note) is a bit more difficult cause you have to overwrite the defcon representation factory generating the glyph cell.
    Adding smart sets is probably the easiest.

    But I guess your proposed solutions are not the best options for the problem...

    however, good luck!