Skip to content

Instantly share code, notes, and snippets.

@LettError
Created February 24, 2018 17:00
Show Gist options
  • Save LettError/a2b2c7dc35f59b5c747512795764405f to your computer and use it in GitHub Desktop.
Save LettError/a2b2c7dc35f59b5c747512795764405f to your computer and use it in GitHub Desktop.
Quick sketch for a replacement for SelectFont for RF3.
# 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