root/trunk/Documentation/TypoTechnica 2005/scripts Folder/Paulus - batch/batch win rename kievit.py

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

initial import

  • Property svn:executable set to
Line 
1 #FLM: Batch win rename Kievit
2
3 #       Paul van der Laan, 2004/09/13
4
5
6
7 from robofab.interface.all.dialogs import GetFolder
8 from robofab.world import RFont, OpenFont, CurrentFont
9 import os
10
11
12 # Een functie om een map met files door te zoeken op vfb files
13 def collectSources(root):
14         files = []
15         ext = ['.vfb']
16         names = os.listdir(root)
17         for n in names:
18                 if os.path.splitext(n)[1] in ext:
19                         files.append(os.path.join(root, n))
20         return files
21
22
23
24 # Rename
25 def renameFont(f, myDest):
26         if f.info.fontName:
27
28                 f.info.fontStyle=64
29                 myStylename="Regular"
30                
31                 myStyle = f.info.styleName
32                 if "Italic" in myStyle:
33                         myStyle = myStyle.replace("Italic", "")
34                         myStylename = "Italic"
35                         f.info.fontStyle = 1
36                
37                 myFamilyname = f.info.familyName + myStyle
38                                
39                 f.info.familyName = myFamilyname
40                 f.info.styleName = myStylename
41                 f.info.fontName = myFamilyname + "-" + myStylename
42                 f.info.fullName = myFamilyname + " " + myStylename
43                 f.info.menuName = myFamilyname
44                 f.info.fondName = myFamilyname
45                
46                 font = fl.font
47                 font.width = "Medium (normal)"
48                 font.tt_version = "Version 1.000 2001 initial release"
49                 font.tt_u_id = "INVD: " + myFamilyname + " " + myStylename + ": 2001"
50                 font.vendor = "INVD"
51                 myFont.panose[0] = 2
52                 myFont.panose[1] = 11
53                 myFont.panose[2] = 0
54                 myFont.panose[3] = 0
55                 myFont.panose[4] = 0
56                 myFont.panose[5] = 0
57                 myFont.panose[6] = 0
58                 myFont.panose[7] = 0
59                 myFont.panose[8] = 0
60                 myFont.panose[9] = 0
61                 font.ms_id = 2
62                
63                 f.update()
64                
65                 myPath = myDest + ":" + myFamilyname + "-" + myStylename + ".vfb"
66                 fl.font.Save(myPath)
67                 print myFamilyname + "-" + myStylename
68
69
70        
71 # main loop
72 mySource = GetFolder()
73 myDest = GetFolder()
74
75 if mySource is not None:
76         myFiles = collectSources(mySource)
77        
78         for myFile in myFiles:
79                 myFont = None
80                 try:
81                         myFont = OpenFont(myFile)
82                         renameFont(myFont, myDest)
83                        
84                 finally:
85                         if myFont is not None:
86                                 myFont.close(False)
87
88 print "Done"
Note: See TracBrowser for help on using the browser.