fonttools/Scripts/RoboFabUFO/ImportUFOBatch.py
Erik van Blokland 617945dcf1 The scripts folder for FontLab as they shipped with Fab 1.1.1.
git-svn-id: http://svn.robofab.com/trunk@22 b5fa9d6c-a76f-4ffd-b3cb-f825fc41095c
2008-01-16 08:14:00 +00:00

40 lines
829 B
Python

#FLM: Import all UFOs in a folder
from robofab.world import NewFont
from robofab.interface.mac.getFileOrFolder import GetFileOrFolder
from robofab.interface.all.dialogs import GetFolder
import os
def globUFO(dir, filter=None):
"""Collect paths for all ufos in dir.
Check for nested dirs.
Optionally, select only ufos which match a filter string.
"""
ufo = []
names = os.listdir(dir)
for n in names:
p = os.path.join(dir, n)
if n[-4:] == ".ufo":
if filter is not None:
if dir.find(filter) <> -1:
ufo.append(p)
else:
ufo.append(p)
continue
if os.path.isdir(p):
ufo += globUFO(p, filter)
return ufo
dir = GetFolder()
ufo = globUFO(dir)
for path in ufo:
font = NewFont()
font.readUFO(path, doProgress=True)
font.update()
vfbPath = path[:-4] + ".vfb"
font.save(vfbPath)
print 'DONE!'