Last active
July 15, 2020 20:55
-
-
Save ryanbugden/b7ae1b8322fadbe92dcd5b5ecf02d35a to your computer and use it in GitHub Desktop.
Opens a slick glyph preview for when you're working. Thanks Juan for the idea; RoboFont.com for the example code on which this is based
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
# menuTitle : Open Glyph Preview Window | |
from vanilla import FloatingWindow | |
from mojo.glyphPreview import GlyphPreview | |
from mojo.roboFont import OpenWindow | |
from mojo.events import addObserver, removeObserver | |
from lib.tools.misc import rgbaToNSColor | |
class GlyphPreviewWindow: | |
def __init__(self): | |
self.w = FloatingWindow((600, 600), "Glyph Preview", minSize=(100, 100)) | |
ns = self.w.getNSWindow() | |
ns.setBackgroundColor_(rgbaToNSColor((1, 1, 1, 1))) | |
ns.setTitlebarAppearsTransparent_(True) | |
ns.setTitlebarHeight_(24) | |
self.w.preview = GlyphPreview((0, 0, 0, 0)) | |
self.w.bind("close", self.shutdown) | |
self.w.open() | |
addObserver(self, "showPreview", "draw") | |
def showPreview(self, notification): | |
g = notification['glyph'] | |
if g is not None: | |
self.w.preview.setGlyph(g) | |
def shutdown(self, window): | |
removeObserver(self, "draw") | |
OpenWindow(GlyphPreviewWindow) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment