def createFontList(fontfiles, fontext='<STR_LIT>'):
fontlist = []<EOL>seen = {}<EOL>for fpath in fontfiles:<EOL><INDENT>verbose.report('<STR_LIT>' % (fpath), '<STR_LIT>')<EOL>fname = os.path.split(fpath)[<NUM_LIT:1>]<EOL>if fname in seen:  continue<EOL>else: seen[fname] = <NUM_LIT:1><EOL>if fontext == '<STR_LIT>':<EOL><INDENT>try:<EOL><INDENT>fh = open(fpath, '<STR_LIT:r>')<EOL><DEDENT>except:<EOL><INDENT>verbose.report("<STR_LIT>" % fpath)<EOL>continue<EOL><DEDENT>try:<EOL><INDENT>try:<EOL><INDENT>font = afm.AFM(fh)<EOL><DEDENT>finally:<EOL><INDENT>fh.close()<EOL><DEDENT><DEDENT>except RuntimeError:<EOL><INDENT>verbose.report("<STR_LIT>"%fpath)<EOL>continue<EOL><DEDENT>prop = afmFontProperty(fpath, font)<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>font = ft2font.FT2Font(str(fpath))<EOL><DEDENT>except RuntimeError:<EOL><INDENT>verbose.report("<STR_LIT>"%fpath)<EOL>continue<EOL><DEDENT>except UnicodeError:<EOL><INDENT>verbose.report("<STR_LIT>")<EOL>continue<EOL><DEDENT>try: prop = ttfFontProperty(font)<EOL>except: continue<EOL><DEDENT>fontlist.append(prop)<EOL><DEDENT>return fontlist<EOL>
A function to create a font lookup list.  The default is to create
a list of TrueType fonts.  An AFM font list can optionally be
created.