SOLVED How to add some graphic label to the glyph cell in font overview

  • Hi Guys,
    I would like to add a system of marking the changes to my script.

    For different reasons, it cannot affect color marking (glyph.colorMark).
    The obvious solution for me would be drawing some graphic label on top of the glyph cells in the font overview. Is there any way to achieve that?

    Thanks in advance for your help!

  • added to the docs as an example. thanks!

  • @frederik Thanks!

  • admin

    I would store your data in the glyph.lib and draw from the lib data.

    glyph.lib["com.rafalbuchner.toolName"] = "changedToSomething"
    def drawCell(self, info):
        glyph = info["glyph"]
        data = glyph.lib.get("com.rafalbuchner.toolName")
        if data:

    the big advantage is the glyph get proper updates when you set or change the data in the glyph.lib.

    good luck!!

  • @gferreira
    Thanks, feel free to use it

  • @RafaŁ-Buchner makes sense to me. nice example for the docs :)

  • I'm not sure if this way of dealing with the problem is proper:
    let's say that I have a list of glyph names that were somehow changed by the "Action".

    I'm labelling the glyphs from the list by:

    1. checking if the event's glyph is in that list
    2. refreshing the glyphs in that list with glyph.changed()
    from import addObserver, removeObserver
    from mojo.drawingTools import *
    import vanilla
    class Test:
        def __init__(self):
            self.w = vanilla.FloatingWindow((200,50),"TEST")
            self.w.bind("close", self.closeCB)
            self.w.button = vanilla.SquareButton((0,0,-0,-0),"Action",callback=self.actionCB)
            self.changedGlyphs = []
            self.f = CurrentFont()
        def drawCell(self, info):
            glyphName = info["glyph"].name
            if glyphName in self.changedGlyphs:
        def actionCB(self,sender):
            self.changedGlyphs = ["a","b","c"]
            # making sure that cells will be labeled:
            # (are cells only labeled after the glyph.changed()?)
            for glyphName in self.changedGlyphs:
        def closeCB(self,sender):
            # cleaning the cells
            for glyphName in self.changedGlyphs:

    Is it ok? or there is there a better way to achieve that?

  • admin

    there are some glyph cell view notifications:

    • glyphCollectionDraw is called and provides the collection view. You can draw on top of all the glyph cells.
    • glyphCellDraw is called for each glyph cell, you can draw additional data inside each cell, this is in glyph coordinates space. The notification provides the glyph, the glyphCell view and the rect of the cell.

    hope this helps!!