Created
February 24, 2018 17:00
-
-
Save LettError/a2b2c7dc35f59b5c747512795764405f to your computer and use it in GitHub Desktop.
Quick sketch for a replacement for SelectFont for RF3.
This file contains hidden or 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
# coding: utf-8 | |
# replacement for robofab's SelectFont | |
import os | |
import vanilla | |
from mojo.roboFont import CurrentFont, CurrentGlyph, AllFonts, OpenWindow | |
class SelectFontWindow(object): | |
def __init__(self, callback=None): | |
self.fonts = {} | |
self.callback = callback | |
for f in AllFonts(): | |
if f.path is None: continue | |
p = os.path.basename(f.path) | |
self.fonts[p] = f | |
self.names = list(self.fonts.keys()) | |
self.names.sort() | |
self.w = vanilla.Window((300,200), "Select UFO") | |
self.w.l = vanilla.List((0,0,0,-30), self.names, doubleClickCallback=self.callbackSelectFont) | |
self.w.open() | |
def callbackSelectFont(self, sender): | |
s = self.w.l.getSelection() | |
if len(s)==1: | |
selectedFont = self.fonts[self.names[s[0]]] | |
if self.callback is not None: | |
self.callback(selectedFont) | |
self.w.close() | |
if __name__ == "__main__": | |
def myFunction(selectedUFO): | |
print("this is the UFO you selected:", selectedUFO) | |
OpenWindow(SelectFontWindow, myFunction) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment