1- #!/usr/bin/python
1+ #!/usr/bin/env python
22
33import os
44import sys
77
88
99__doc__ = """
10- buildAll v1.1 - Aug 04 2013
10+ buildAll v1.2 - Dec 01 2019
1111
1212This script takes a path to a folder as input, finds all the Type 1 fonts
1313(.pfa files) or UFO fonts inside that folder and its subdirectories, and
2222Versions:
2323v1.0 - Feb 22 2013 - Initial release
2424v1.1 - Aug 04 2013 - Added support for UFO files
25+ v1.2 - Dec 01 2019 - Python 3
2526"""
2627
2728kFontProjFile = "current.fpr"
@@ -51,7 +52,7 @@ def getFontPaths(path):
5152
5253def doTask (fonts ):
5354 totalFonts = len (fonts )
54- print "%d fonts found\n " % totalFonts
55+ print ( "%d fonts found\n " % totalFonts )
5556 i = 1
5657
5758 for font in fonts :
@@ -61,16 +62,16 @@ def doTask(fonts):
6162 # Change current directory to the folder where the font is contained
6263 os .chdir (folderPath )
6364
64- print '*******************************'
65- print 'Building %s...(%d/%d)' % (styleName , i , totalFonts )
65+ print ( '*******************************' )
66+ print ( 'Building %s...(%d/%d)' % (styleName , i , totalFonts ) )
6667 cmd = 'makeotf -f "%s" -gs -r' % fontFileName # -gs option: only the glyphs listed in the GOADB file will be included in OTF
6768 # cmd = 'makeotf -f "%s" -addn -r' % fontFileName # adds marking notdef glyph
6869 popen = Popen (cmd , shell = True , stdout = PIPE )
6970 popenout , popenerr = popen .communicate ()
7071 if popenout :
71- print popenout
72+ print ( popenout . decode ( 'utf-8' ))
7273 if popenerr :
73- print popenerr
74+ print ( popenerr . decode ( 'utf-8' ))
7475 i += 1
7576
7677 # Delete project file
@@ -88,7 +89,7 @@ def run():
8889
8990 # make sure the path is valid
9091 if not os .path .isdir (baseFolderPath ):
91- print 'Invalid directory.'
92+ print ( 'Invalid directory.' )
9293 return
9394
9495 # if a path is not provided, use the current directory
@@ -101,16 +102,16 @@ def run():
101102 if len (fontsList ):
102103 doTask (fontsList )
103104 else :
104- print "No fonts found"
105+ print ( "No fonts found" )
105106 return
106107
107108 t2 = time .time ()
108109 elapsedSeconds = t2 - t1
109110
110111 if (elapsedSeconds / 60 ) < 1 :
111- print 'Completed in %.1f seconds.' % elapsedSeconds
112+ print ( 'Completed in %.1f seconds.' % elapsedSeconds )
112113 else :
113- print 'Completed in %.1f minutes.' % (elapsedSeconds / 60 )
114+ print ( 'Completed in %.1f minutes.' % (elapsedSeconds / 60 ) )
114115
115116
116117if __name__ == '__main__' :
0 commit comments