[reportlab-users] Intermittent failure to find font, followed by IOError

Robin Becker robin at reportlab.com
Thu Oct 29 10:43:10 EDT 2009


My hack to bruteForceSearchForAFM missed out a comma, here's a better version

def bruteForceSearchForAFM(faceName):
"""Looks in all AFM files on path for face with given name.

Returns AFM file name or None. Ouch!"""
from reportlab.rl_config import T1SearchPath

for dirname in T1SearchPath:
if not rl_isdir(dirname): continue
possibles = rl_glob(dirname + os.sep + '*.[aA][fF][mM]')
for possible in possibles:
try:
topDict, glyphDict = parseAFMFile(possible)
if topDict['FontName'] == faceName:
return possible
except:
t,v,b=sys.exc_info()
v.args = (' '.join(v.args)+', while looking for faceName=%r' %
faceName,)
raise

--
Robin Becker


More information about the reportlab-users mailing list