root/trunk/Documentation/TypoTechnica 2005/scripts Folder/Paulus - batch/batch generate win unix.py

Revision 1, 1.6 kB (checked in by erik, 3 years ago)

initial import

  • Property svn:executable set to
Line 
1 #FLM: Batch generate Win & Unix
2
3 # Generates two formats at once:
4 #   Windows PS Type 1
5 #   Unix PS Type 1
6
7 from robofab.interface.all.dialogs import GetFolder
8 from robofab.world import RFont, OpenFont
9 import os
10
11 # Een functie om een map met files door te zoeken op vfb files
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 # A little function for making folders. we'll need it later.
22 def makeFolder(path):
23         #if the path doesn't exist, make it!
24         if not os.path.exists(path):
25                 os.makedirs(path)
26
27 # maak verschillende mapjes aan voor de fontformaten
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 # genereer de drie formaten
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         # print unique ID en naam in het output window
44
45 # dialog voor het selecteren van een folder
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'
Note: See TracBrowser for help on using the browser.