Skip to content

Instantly share code, notes, and snippets.

@okay-type
Last active August 29, 2015 14:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save okay-type/ca234fbec798de789964 to your computer and use it in GitHub Desktop.
Save okay-type/ca234fbec798de789964 to your computer and use it in GitHub Desktop.
aPreviewer.py for Robofont, show the current glyph big and small as a simple alternative to looking at drawings in space center.
# jackson @ okaytype.com
# simpler big glyph preview window v3
from vanilla import Window
from defconAppKit.windows.baseWindow import BaseWindowController
from mojo import events
from mojo.events import addObserver, removeObserver
from mojo.glyphPreview import GlyphPreview
class BigGlyphPreview(BaseWindowController):
def __init__(self):
self.font = CurrentFont()
self.glyph = CurrentGlyph()
## create window
self.w = Window((720, 600), self.glyphName(), minSize=(72, 86))
self.w.preview = GlyphPreview((0, 20, 0, -20))
self.glyphChanged(CurrentGlyph())
events.addObserver(self, "glyphChanged", "currentGlyphChanged")
addObserver(self, "stopObservers", "fontWillClose")
self.setUpBaseWindowBehavior()
self.w.open()
def glyphName(self):
if CurrentGlyph():
return CurrentGlyph().name
else:
return 'Select a Glyph'
def windowCloseCallback(self, sender):
events.removeObserver(self, "currentGlyphChanged")
events.removeObserver(self, "fontWillClose")
super(BigGlyphPreview, self).windowCloseCallback(sender)
def glyphChanged(self, info):
self.w.setTitle(self.glyphName())
self.font = CurrentFont()
self.glyph = CurrentGlyph()
self.w.preview.setGlyph(CurrentGlyph())
BigGlyphPreview()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment