|
Revision 1, 0.9 kB
(checked in by erik, 3 years ago)
|
initial import
|
- Property svn:executable set to
|
| Line | |
|---|
| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 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 |
|
|---|
| 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 |
|
|---|
| 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" |
|---|