root/trunk/Documentation/TypoTechnica 2005/scripts Folder/Paulus - batch/batch remove glyphs.py

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

initial import

  • Property svn:executable set to
Line 
1 #FLM: Batch remove glyphs
2
3 #       Paul van der Laan, 2004/10/25
4
5
6 from robofab.interface.all.dialogs import GetFolder
7 from robofab.world import RFont, OpenFont, CurrentFont
8 import os
9
10 myBlacklist = ("nbspace", ".notdef", ".null")
11
12
13 # Een functie om een map met files door te zoeken op vfb files
14 def collectSources(root):
15         files = []
16         ext = ['.vfb']
17         names = os.listdir(root)
18         for n in names:
19                 if os.path.splitext(n)[1] in ext:
20                         files.append(os.path.join(root, n))
21         return files
22
23 # main loop
24 mySource = GetFolder()
25 if mySource is not None:
26         myFiles = collectSources(mySource)
27         for myFile in myFiles:
28                 myrfFont = None
29                 try:
30                         myrfFont = OpenFont(myFile)
31                         for myGlyph in myBlacklist:
32                                 if myrfFont.has_key(myGlyph):
33                                         myrfFont.removeGlyph(myGlyph)
34                                         print myGlyph, "removed from", myrfFont.info.familyName + "-" + myrfFont.info.styleName
35                         myrfFont.update()
36                         myrfFont.save()
37                 finally:
38                         if myrfFont is not None:
39                                 myrfFont.close(False)
40 print "Done"
Note: See TracBrowser for help on using the browser.