Last active
June 21, 2023 17:28
-
-
Save arialcrime/b5bd496531bcc3ab76c4fe54e6bc14f1 to your computer and use it in GitHub Desktop.
template snippet for a show/hide script in robofont glyph editor window
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #menuTitle: Show/Hide Template | |
| from mojo.subscriber import Subscriber, registerGlyphEditorSubscriber, unregisterGlyphEditorSubscriber, listRegisteredSubscribers | |
| class TemplateSubscriber(Subscriber): | |
| debug = True | |
| # --- base methods --- # | |
| def build(self): | |
| glyphEditor = self.getGlyphEditor() | |
| self.container = glyphEditor.extensionContainer( | |
| identifier="XXX.XXXXXXXXX.TemplateSubscriber", | |
| location="foreground", | |
| clear=True | |
| ) | |
| def started(self): | |
| self.draw() | |
| def destroy(self): | |
| self.container.clearSublayers() | |
| # --- subscribers --- # | |
| def glyphEditorDidSetGlyph(self, info): | |
| self.draw() | |
| glyphEditorGlyphDidChangeDelay = 0 | |
| def glyphEditorGlyphDidChange(self, info): | |
| self.draw() | |
| # --- drawing routine --- # | |
| def draw(self): | |
| ############################### | |
| # your drawing code goes here # | |
| ############################### | |
| if __name__ == '__main__': | |
| for s in listRegisteredSubscribers(): | |
| if 'TemplateSubscriber' in s.getIdentifier(): | |
| unregisterGlyphEditorSubscriber(s) | |
| else: | |
| registerGlyphEditorSubscriber(TemplateSubscriber) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment