Getting the glyph and its font

RoboFont Forums Bugs Getting the glyph and its font

Tagged: 

This topic contains 4 replies, has 2 voices, and was last updated by  Anonymous 2 years, 4 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #6138

    Anonymous

    Hi,
    In a class derived from BaseEventTool, I use
    g = self.getGlyph()
    f = g.getParent()
    in order to obtain the font containing the glyph g.
    However, when I have two opened fonts F1 and F2 and two GlyphWindows opened (one from each font : g1 from F1 and g2 from F2), and when I go from one glyph window to the other, the following code :
    print g.name, g.getParent.fileName
    gives me : g1 F2 or g2 F1
    and after some more clicking, I finally get correct values (g1 F1 or g2 F2)

    There seem to be only partially updated information when switching windows.
    Regards,
    Samuel

    #6139

    frederik
    Keymaster

    hi

    could you make an small example?

    I cannot reproduce this issue, with a quick test…

    thanks

    from mojo.events import BaseEventTool, installTool
    
    class TestTool(BaseEventTool):
        
        def currentGlyphChanged(self):
            g = self.getGlyph()
            f = g.getParent()
            print g.name, f
        
    installTool(TestTool())
    
    #6140

    Anonymous

    [ With Version 1.6 (built 1410152315) ]
    Using your example TestTool :
    – Open two fonts F1 and F2
    – Open glyph g1 from font F1
    (now there are three windows opened, plus the output window)
    – Bring the window for the font F2 to the front
    – click on the glyphs grid, on a glyph g2 (with a name different from g1)
    Now you should observe “g1 <F2>” in the output window

    [Another weirdness: the callbacks “viewDidChangeGlyph” and “currentGlyphChanged” are called before “becomeActive”]
    Best regards,
    Samuel

    #6146

    frederik
    Keymaster

    Hi

    the mixed parents will be fixed in the next update, thanks for reporting

    one thing: a tool.getGlyph() method will always return a glyph from a glyph view, if you select a font window, it will send you a currentGlyphChanged notification, but the glyph will not actually change when using the tool.getGlyph(). To get the global current glyph use CurrentGlyph()

    the other weirdness: see https://github.com/typemytype/RoboFontExamples/blob/master/observers/eventObserver.py

    a tool can become active separately from a currentGlyphChanged or viewDidChangeGlyph

    #6149

    Anonymous

    Thank you for fixing this.!
    I’ll use your eventObserver example to get a better understanding of when each event is triggered.
    Regards,
    Samuel

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.