Skip to content

Instantly share code, notes, and snippets.

@typemytype
Last active August 28, 2023 11:13
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save typemytype/58d60bd29ff462afa8c4d30a0c564e13 to your computer and use it in GitHub Desktop.
Save typemytype/58d60bd29ff462afa8c4d30a0c564e13 to your computer and use it in GitHub Desktop.
show multiple glyphs in a glyph editor RF4
# this scripts add a input field at the top of your glyph window
# the input text is converted to a list of glyphs objects
# and set into the glyph editor
# jump around with `esc` and select to edit by hitting a glyph
from mojo.UI import GlyphSequenceEditText
from mojo.subscriber import Subscriber, registerGlyphEditorSubscriber
class GlyphLineController(Subscriber):
debug = True
def build(self):
glyphEditor = self.getGlyphEditor()
glyph = glyphEditor.getGlyph()
self.view = GlyphSequenceEditText((10, 10, 150, 22), glyph.font, callback=self.glyphSequenceEditTextCallback)
glyphEditor.addGlyphEditorSubview(self.view, "com.typemytype.GlyphLine")
def glyphSequenceEditTextCallback(self, sender):
glyphNames = sender.get()
glyphEditor = self.getGlyphEditor()
glyph = glyphEditor.getGlyph()
if glyph is None:
layer = CurrentFont()
else:
layer = glyph.layer
glyphs = [layer[glyphName] for glyphName in glyphNames if glyphName in layer]
glyphEditor.setGlyphs(glyphs)
registerGlyphEditorSubscriber(GlyphLineController)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment