Skip to content

Instantly share code, notes, and snippets.

@okay-type
Last active March 8, 2025 14:57
Show Gist options
  • Select an option

  • Save okay-type/5ff7c9a24162884680b06461a1352abb to your computer and use it in GitHub Desktop.

Select an option

Save okay-type/5ff7c9a24162884680b06461a1352abb to your computer and use it in GitHub Desktop.
return to the previous CurrentGlyph rf4
from mojo.subscriber import Subscriber, registerRoboFontSubscriber
from mojo.UI import SetCurrentGlyphByName
'''
keep track of the most recent currentGlyph and return to it using ⇧+,
recent update:
no longer tied to the edit glyph window - you can now close a glyph, open a new glyph, and then ⇧+, back to the previous glyph
'''
class previousCurrentGlyph(Subscriber):
debug = False
def build(self):
self.previousGlyph = [None, None]
def glyphEditorDidSetGlyph(self, info):
glyph = info['glyph']
if glyph is None:
return
if glyph.name != self.previousGlyph[1]:
self.previousGlyph = [self.previousGlyph[1], glyph.name]
def glyphEditorDidKeyDown(self, info):
deviceState = info['iterations'][0]['deviceState']
keyDown = deviceState['keyDown']
shiftDown = deviceState['shiftDown']
if keyDown == '<' and shiftDown != 0 and self.previousGlyph[0] != None:
SetCurrentGlyphByName(self.previousGlyph[0])
registerRoboFontSubscriber(previousCurrentGlyph)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment