Skip to content

Instantly share code, notes, and snippets.

@arialcrime
Last active June 21, 2023 17:28
Show Gist options
  • Select an option

  • Save arialcrime/b5bd496531bcc3ab76c4fe54e6bc14f1 to your computer and use it in GitHub Desktop.

Select an option

Save arialcrime/b5bd496531bcc3ab76c4fe54e6bc14f1 to your computer and use it in GitHub Desktop.
template snippet for a show/hide script in robofont glyph editor window
#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