def findSystemFonts(fontpaths=None, fontext='<STR_LIT>'):
fontfiles = {}<EOL>fontexts = get_fontext_synonyms(fontext)<EOL>if fontpaths is None:<EOL><INDENT>if sys.platform == '<STR_LIT:win32>':<EOL><INDENT>fontdir = win32FontDirectory()<EOL>fontpaths = [fontdir]<EOL>for f in win32InstalledFonts(fontdir):<EOL><INDENT>base, ext = os.path.splitext(f)<EOL>if len(ext)><NUM_LIT:1> and ext[<NUM_LIT:1>:].lower() in fontexts:<EOL><INDENT>fontfiles[f] = <NUM_LIT:1><EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>fontpaths = x11FontDirectory()<EOL>if sys.platform == '<STR_LIT>':<EOL><INDENT>for f in OSXInstalledFonts(fontext=fontext):<EOL><INDENT>fontfiles[f] = <NUM_LIT:1><EOL><DEDENT><DEDENT>for f in get_fontconfig_fonts(fontext):<EOL><INDENT>fontfiles[f] = <NUM_LIT:1><EOL><DEDENT><DEDENT><DEDENT>elif isinstance(fontpaths, str):<EOL><INDENT>fontpaths = [fontpaths]<EOL><DEDENT>for path in fontpaths:<EOL><INDENT>files = []<EOL>for ext in fontexts:<EOL><INDENT>files.extend(glob.glob(os.path.join(path, '<STR_LIT>'+ext)))<EOL>files.extend(glob.glob(os.path.join(path, '<STR_LIT>'+ext.upper())))<EOL><DEDENT>for fname in files:<EOL><INDENT>fontfiles[os.path.abspath(fname)] = <NUM_LIT:1><EOL><DEDENT><DEDENT>return [fname for fname in list(fontfiles.keys()) if os.path.exists(fname)]<EOL>
Search for fonts in the specified font paths.  If no paths are
given, will use a standard set of system paths, as well as the
list of fonts tracked by fontconfig if fontconfig is installed and
available.  A list of TrueType fonts are returned by default with
AFM fonts as an option.