11#!/usr/bin/python
22
3- __copyright__ = __license__ = """
3+ import os
4+ import sys
5+ import time
6+ from subprocess import Popen , PIPE
7+
8+ __copyright__ = __license__ = """
49Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
5-
10+
611Permission is hereby granted, free of charge, to any person obtaining a
7- copy of this software and associated documentation files (the "Software"),
8- to deal in the Software without restriction, including without limitation
9- the rights to use, copy, modify, merge, publish, distribute, sublicense,
10- and/or sell copies of the Software, and to permit persons to whom the
12+ copy of this software and associated documentation files (the "Software"),
13+ to deal in the Software without restriction, including without limitation
14+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
15+ and/or sell copies of the Software, and to permit persons to whom the
1116Software is furnished to do so, subject to the following conditions:
12-
17+
1318The above copyright notice and this permission notice shall be included in
1419all copies or substantial portions of the Software.
15-
20+
1621THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1823FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2227DEALINGS IN THE SOFTWARE.
2328"""
2429
2530__doc__ = """
2631buildAll v1.1 - Aug 04 2013
2732
2833This script takes a path to a folder as input, finds all the Type 1 fonts
29- (.pfa files) or UFO fonts inside that folder and its subdirectories, and
30- builds the OpenType (.otf) fonts using the FDK's makeotf tool. If a path is
34+ (.pfa files) or UFO fonts inside that folder and its subdirectories, and
35+ builds the OpenType (.otf) fonts using the FDK's makeotf tool. If a path is
3136not provided, the script will use the current path as the top-most directory.
3237The script ignores MM PFA fonts, usually named 'mmfont.pfa'.
33- The Type 1 fonts can also be in plain text format (.txt) where the Private
38+ The Type 1 fonts can also be in plain text format (.txt) where the Private
3439and CharStrings dictionaries are not encrypted. These files can be obtained
3540by using the FDK's detype1 tool.
3641
4045v1.1 - Aug 04 2013 - Added support for UFO files
4146"""
4247
43- import sys , os , time
44- from subprocess import Popen , PIPE
45-
4648kFontProjFile = "current.fpr"
4749kFontTXT = "font.txt"
4850
49- fontsList = []
50-
5151
5252def getFontPaths (path ):
53+ fontsList = []
5354 for r , folders , files in os .walk (path ):
5455 fileAndFolderList = folders [:]
5556 fileAndFolderList .extend (files )
56-
57+
5758 for item in fileAndFolderList :
58- if (item [- 4 :].lower () in [".pfa" ] and item not in ["mmfont.pfa" ]) or (item in [kFontTXT ]) or (item [- 4 :].lower () in [".ufo" ]):
59+ fileName , extension = os .path .splitext (item )
60+ extension = extension .lower ()
61+ if extension == ".pfa" and not fileName == "mmfont" :
62+ fontsList .append (os .path .join (r , item ))
63+ elif extension == ".txt" and fileName == "font" :
5964 fontsList .append (os .path .join (r , item ))
65+ elif extension == ".ufo" :
66+ fontsList .append (os .path .join (r , item ))
67+ else :
68+ continue
69+
70+ return fontsList
6071
6172
6273def doTask (fonts ):
@@ -65,16 +76,16 @@ def doTask(fonts):
6576 i = 1
6677
6778 for font in fonts :
68- folderPath , fontFileName = os .path .split (font ) # path to the folder where the font is contained and the font's file name
69- styleName = os .path .basename (folderPath ) # name of the folder where the font is contained
79+ folderPath , fontFileName = os .path .split (font )
80+ styleName = os .path .basename (folderPath )
7081
7182 # Change current directory to the folder where the font is contained
7283 os .chdir (folderPath )
7384
7485 print '*******************************'
7586 print 'Building %s...(%d/%d)' % (styleName , i , totalFonts )
7687 cmd = 'makeotf -f "%s" -gs -r' % fontFileName # -gs option: only the glyphs listed in the GOADB file will be included in OTF
77- # cmd = 'makeotf -f "%s" -addn -r' % fontFileName # adds marking notdef glyph
88+ # cmd = 'makeotf -f "%s" -addn -r' % fontFileName # adds marking notdef glyph
7889 popen = Popen (cmd , shell = True , stdout = PIPE )
7990 popenout , popenerr = popen .communicate ()
8091 if popenout :
@@ -106,9 +117,8 @@ def run():
106117 baseFolderPath = os .getcwd ()
107118
108119 t1 = time .time ()
120+ fontsList = getFontPaths (baseFolderPath )
109121
110- getFontPaths (baseFolderPath )
111-
112122 if len (fontsList ):
113123 doTask (fontsList )
114124 else :
@@ -117,7 +127,7 @@ def run():
117127
118128 t2 = time .time ()
119129 elapsedSeconds = t2 - t1
120-
130+
121131 if (elapsedSeconds / 60 ) < 1 :
122132 print 'Completed in %.1f seconds.' % elapsedSeconds
123133 else :
0 commit comments