Last active
August 28, 2023 11:13
-
-
Save typemytype/58d60bd29ff462afa8c4d30a0c564e13 to your computer and use it in GitHub Desktop.
show multiple glyphs in a glyph editor RF4
This file contains 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
# 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