Open davelab6 opened 11 years ago
I've expanded the above into a generic cleanup script that loads a font and does some basic maintenance.
Andrew Miller
cleanup.py:
#! /usr/bin/env python
import fontforge
import sys
fontfile = sys.argv[1]
try:
font = fontforge.open (fontfile)
except EnvironmentError:
sys.exit (1)
font.selection.all ()
font.removeOverlap ()
font.simplify ()
font.correctDirection ()
font.round ()
for glyph in font:
if font[glyph].unicode != -1:
font[glyph].glyphname = fontforge.nameFromUnicode (font[glyph].unicode, "AGL without afii")
font.save (fontfile)
Nice! :) Would be great to have some print() methods in there (or logging() etc) to tell the user what glyphs change in each step...
Convenient script. Just watch out for removing overlaps before correcting the direction. This causes the removal of inpainted regions before they get a chance to be fixed.
Do this instead:
font.selection.all ()
font.correctDirection ()
font.removeOverlap ()
font.simplify ()
font.round ()
This python script was made by me an Andrew Miller [A.J.Miller@bcs.org.uk] and could be a nice example of python scripting; it renames all glyphs to the "AGL without afii" namelist: