root/trunk/Documentation/TypoTechnica 2005/scripts Folder/Paulus - batch/batch font report.py

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

initial import

  • Property svn:executable set to
Line 
1 #FLM: Batch font report
2
3 from robofab.interface.all.dialogs import GetFolder
4 from robofab.world import OpenFont, CurrentFont
5 import os
6
7
8 # Een functie om een map met files door te zoeken op vfb files
9 def collectSources(root):
10         files = []
11         ext = ['.vfb']
12         names = os.listdir(root)
13         for n in names:
14                 if os.path.splitext(n)[1] in ext:
15                         files.append(os.path.join(root, n))
16         return files
17
18
19 # main loop
20 myFolder = GetFolder()
21 myPath = myFolder + ":fontreport.txt"
22
23
24 myRecord = ["Filename", "Glyphs", "Kerning pairs", "Family name", "Weight", "Weight code", "Width", "Style", "Style name", "Font name", "Full name", "Menu name", "FOND name", "OT Family name", "OT Style name" ,"OT Mac name", "Year", "Copyright", "Trademark", "Notice", "Designer", "Designer URL", "Vendor URL", "Version", "Revision", "Version", "TrueType version", "TrueType unique ID", "Type 1 unique ID", "TrueType vendor", "PANOSE", "PCL ID", "VP ID", "MS ID", "UPM", "Ascender", "Descender", "Cap height", "X height", "Italic angle", "Slant angle", "Underline", "Thickness", "Monospaced", "MS Charset", "Default char", "Mac FOND ID", "Blue fuzz", "Blue scale", "Blue shift", "Blue values",
25 "Other blues", "Family blues", "Other family blues", "Force bold", "Horizontal stems", "Vertical stems"]
26
27 myLen=len(myRecord)
28
29 myFile = open(myPath, "w")
30 for myItem in myRecord:
31         myFile.write(str(myItem + "\t"))
32 myFile.write("\r")
33 myFile.close()
34
35 if myFolder is not None:
36         myFiles = collectSources(myFolder)
37        
38         for mySourcefile in myFiles:
39                 myflFont = None
40                 try:
41                         myrfFont = OpenFont(mySourcefile)
42                         myflFont = fl.font
43                        
44                         for x in range(myLen):
45                                 myRecord[x]=""
46
47                         if myflFont.file_name:
48                                 myFilename = str(myflFont.file_name).split(":")
49                                 myRecord[0] = myFilename[-1]
50                         myRecord[1] = str(len(myflFont))
51                         myRecord[2] = str(len(myrfFont.kerning.keys()))
52                        
53                         if myflFont.family_name: myRecord[3] = str(myflFont.family_name)
54                         if myflFont.weight: myRecord[4] = str(myflFont.weight) 
55                         myRecord[5] = str(myflFont.weight_code)
56                         if myflFont.width: myRecord[6] = str(myflFont.width)
57                         myRecord[7] = str(myflFont.font_style)
58                                 # 1=italic, 32=bold, 64=regular
59                         if myflFont.style_name: myRecord[8] = str(myflFont.style_name) 
60                         if myflFont.font_name: myRecord[9] = str(myflFont.font_name)
61                         if myflFont.full_name: myRecord[10] = str(myflFont.full_name)
62                         if myflFont.menu_name: myRecord[11] = str(myflFont.menu_name)
63                         if myflFont.apple_name: myRecord[12] = str(myflFont.apple_name)
64                        
65                         if myflFont.pref_family_name: myRecord[13] = str(myflFont.pref_family_name)
66                         if myflFont.pref_style_name: myRecord[14] = str(myflFont.pref_style_name)
67                         if myflFont.mac_compatible: myRecord[15] = str(myflFont.mac_compatible)
68                        
69                         myRecord[16] = str(myflFont.year)
70                         if myflFont.copyright: myRecord[17] = str(myflFont.copyright)
71                         if myflFont.trademark: myRecord[18] = str(myflFont.trademark)
72                         if myflFont.notice: myRecord[19] = str(myflFont.notice)
73                        
74                         if myflFont.designer: myRecord[20] = str(myflFont.designer)
75                         if myflFont.designer_url: myRecord[21] = str(myflFont.designer_url)
76                         if myflFont.vendor_url: myRecord[22] = str(myflFont.vendor_url)
77                        
78                         myRecord[23] = str(myflFont.version_major)
79                         myRecord[24] = str(myflFont.version_minor)
80                         if myflFont.version: myRecord[25] = str(myflFont.version)
81                         if myflFont.tt_version: myRecord[26] = str(myflFont.tt_version)
82                        
83                         if myflFont.tt_u_id: myRecord[27] = str(myflFont.tt_u_id)
84                         myRecord[28] = str(myflFont.unique_id)
85                         if myflFont.vendor: myRecord[29] = str(myflFont.vendor)
86                        
87                         if myflFont.panose: myRecord[30] = str(myflFont.panose)
88                        
89                         myRecord[31] = str(myflFont.pcl_id)
90                         myRecord[32] = str(myflFont.vp_id)
91                         myRecord[33] = str(myflFont.ms_id)
92                        
93                         myRecord[34] = str(myflFont.upm)
94                        
95                         myRecord[35] = str(myflFont.ascender[0])
96                         myRecord[36] = str(myflFont.descender[0])
97                         myRecord[37] = str(myflFont.cap_height[0])
98                         myRecord[38] = str(myflFont.x_height[0])
99                         myRecord[39] = str(myflFont.italic_angle)
100                         myRecord[40] = str(myflFont.slant_angle)
101                         myRecord[41] = str(myflFont.underline_position)
102                         myRecord[42] = str(myflFont.underline_thickness)
103                         myRecord[43] = str(myflFont.is_fixed_pitch)
104                        
105                         myRecord[44] = str(myflFont.ms_charset)
106                         if myflFont.default_character: myRecord[45] = str(myflFont.default_character)
107                         myRecord[46] = str(myflFont.fond_id)
108                        
109                         myRecord[47] = str(myflFont.blue_fuzz[0])
110                         myRecord[48] = str(myflFont.blue_scale[0])
111                         myRecord[49] = str(myflFont.blue_shift[0])
112                         myRecord[50] = str(myflFont.blue_values[0])
113                         myRecord[51] = str(myflFont.other_blues[0])
114                         myRecord[52] = str(myflFont.family_blues[0])
115                         myRecord[53] = str(myflFont.family_other_blues[0])
116                         myRecord[54] = str(myflFont.force_bold[0])
117                         myRecord[55] = str(myflFont.stem_snap_h[0])
118                         myRecord[56] = str(myflFont.stem_snap_v[0])
119                        
120                         myFile = open(myPath, "r+")
121                         myFile.seek(0,2)
122                         for myItem in myRecord:
123                                 myFile.write(str(myItem + "\t"))
124                         myFile.write("\r")
125                         myFile.close()
126
127                 finally:
128                         if myrfFont is not None:
129                                 myrfFont.close(False)
130
131 print "Done"
Note: See TracBrowser for help on using the browser.