I managed to write a script that would give the vertical center of a single glyph. Now I have been trying to expand it to give the centers of a list of glyphs with no luck. The script below only gives the center of the last glyph in the list. So what am I doing wrong here?
# Find All Centers
import os
from robofab.world import CurrentFont
from robofab.interface.all.dialogs import GetFolder
f = CurrentFont()
tString = "zero minus plus equal"
glyphList = tString.split(" ")
def collectData(f):
path = GetFolder()
if path:
collectedData = []
for i in glyphList:
g = fl.font[fl.font.FindGlyph(i)]
rect = g.GetBoundingRect()
gcenter = str(rect.height / 2)
collectedData.append("g.name: "+g.name+", "+"gcenter: "+gcenter)
collectedData.sort()
collectedData = "\n".join(collectedData)
theFileName = os.path.basename(f.path)
theFileName = theFileName.split(".")[0] + ".txt"
thePath = os.path.join(path,theFileName)
theFile = open(thePath,"w")
theFile.write(collectedData)
theFile.close()
print "Done with %s!" % f.info.fontName
if len(f) != 0:
collectData(f)
George