Skip to content

Instantly share code, notes, and snippets.

Last active November 30, 2015 20:38
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
# jackson
# v0.3 28 Nov 15
# uses Version Minor to increment font names i.e.:
# Family Name v1
from vanilla import *
import os
from robofab.interface.all.dialogs import GetFolder
class UpVersion():
def __init__(self):
# create a window
self.w = Window((250, 200), "UpVersion")
L = 20
W = -20
T = 10
H = 30
# create button
self.w.b = Button((L, T, W, H), 'Save New Versions', callback=self.UpVersionCallback)
# create check boxes
self.w.eb = EditText((L, T+40, W, H-5), self.editTextGet(), callback=self.editTextCallback)
self.w.c1 = CheckBox((L, T+70, W, H), "Delete Mark Colors", callback=self.cb1Callback, value=False)
self.w.c2 = CheckBox((L, T+90, W, H), "Delete Layers", callback=self.cb2Callback, value=True)
self.w.c3 = CheckBox((L, T+110, W, H), "Delete Guides", callback=self.cb3Callback, value=False)
# open the window
def editTextGet(self):
f = CurrentFont()
if f:
return str(
return '0'
def editTextCallback(self, sender):
def cb1Callback(self, sender):
def cb2Callback(self, sender):
def cb3Callback(self, sender):
def UpVersionCallback(self, sender):
# get the value from the box
print 'test UpVersionCallback'
if self.w.c1.get() == 1:
if self.w.c2.get() == 1:
if self.w.c3.get() == 1:
print ''
def RemoveMarks(self):
for font in AllFonts():
for glyph in font:
glyph.mark = None
def RemoveLayers(self): # repeate a few times since it was occassionally missing layers and I'm lazy
for font in AllFonts():
for layer in font.layerOrder:
for layer in font.layerOrder:
for layer in font.layerOrder:
def RemoveGuides(self):
for font in AllFonts():
for guide in font.guides:
for g in font:
for guide in g.guides:
def NewVersion(self, revisionnumber):
for font in AllFonts():
# add 'v#' to font family name
familyname =" v"+str(, "")
fontname = familyname + " v" + str(revisionnumber) = int(revisionnumber) = 0 = fontname
# update style map name, removing ' Italic' for style linking = + ' ' +' Italic', '')
# clean up naming, this should be a check option in the future = None = None = None = None = None = None = None
# truncate file name parts
fileName = os.path.basename(font.path)
pathName = font.path.split(fileName)
shortfamilyname =" v"+str(, "")[:12]+"-v"+str(revisionnumber)
if "Italic" in
shortstylename ='Italic', '')
shortstylename = shortstylename[:11]
shortstylename = shortstylename+'Itlc'
shortstylename =[:11]
# save new file
newfName = shortfamilyname+"-"+shortstylename+"."+fileName.split(".")[1]
newfName = newfName.replace(" ", "")
newPath = os.path.join(pathName[0]+newfName)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment