| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
from robofab.interface.all.dialogs import GetFolder |
|---|
| 8 |
from robofab.world import RFont, OpenFont |
|---|
| 9 |
import os |
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
def collectSources(root): |
|---|
| 13 |
files = [] |
|---|
| 14 |
ext = ['.vfb'] |
|---|
| 15 |
names = os.listdir(root) |
|---|
| 16 |
for n in names: |
|---|
| 17 |
if os.path.splitext(n)[1] in ext: |
|---|
| 18 |
files.append(os.path.join(root, n)) |
|---|
| 19 |
return files |
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
def makeFolder(path): |
|---|
| 23 |
|
|---|
| 24 |
if not os.path.exists(path): |
|---|
| 25 |
os.makedirs(path) |
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
def makeDestination(root): |
|---|
| 29 |
basePath = os.path.join(root, 'Generated',) |
|---|
| 30 |
winPath = os.path.join(root, 'Generated', 'win ps type 1') |
|---|
| 31 |
makeFolder(winPath) |
|---|
| 32 |
unixPath = os.path.join(root, 'Generated', 'unix ps type 1') |
|---|
| 33 |
makeFolder(unixPath) |
|---|
| 34 |
return basePath |
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
def generateOne(f, dstDir): |
|---|
| 38 |
dstWin = os.path.join(dstDir, 'win ps type 1') |
|---|
| 39 |
f.generate('pctype1', dstWin) |
|---|
| 40 |
dstUnix = os.path.join(dstDir, 'unix ps type 1') |
|---|
| 41 |
f.generate('pctype1ascii', dstUnix) |
|---|
| 42 |
print "%s - %s"%(f.info.uniqueID, f.info.fullName) |
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
f = GetFolder() |
|---|
| 47 |
|
|---|
| 48 |
if f is not None: |
|---|
| 49 |
paths = collectSources(f) |
|---|
| 50 |
dstDir = makeDestination(f) |
|---|
| 51 |
|
|---|
| 52 |
print 'UniqueID Full fontname' |
|---|
| 53 |
print '-------------------------------------------' |
|---|
| 54 |
|
|---|
| 55 |
for f in paths: |
|---|
| 56 |
font = None |
|---|
| 57 |
try: |
|---|
| 58 |
font = OpenFont(f) |
|---|
| 59 |
generateOne(font, dstDir) |
|---|
| 60 |
|
|---|
| 61 |
finally: |
|---|
| 62 |
if font is not None: |
|---|
| 63 |
fl.font.modified = 0 |
|---|
| 64 |
font.close(False) |
|---|
| 65 |
|
|---|
| 66 |
print 'done' |
|---|