def get_fontconfig_fonts(fontext='ttf'):
 try:
  import commands
 except ImportError:
  return {}
 fontext = get_fontext_synonyms(fontext)
 fontfiles = {}
 (status, output) = commands.getstatusoutput('fc-list file')
 if (status == 0):
  for line in output.split('\n'):
   fname = line.split(':')[0]
   if ((os.path.splitext(fname)[1][1:] in fontext) and os.path.exists(fname)):
    fontfiles[fname] = 1
 return fontfiles

def get_fontconfig_fonts ( fontext = 'ttf' ) : try : import commands except ImportError : return { } fontext = get_fontext_synonyms ( fontext ) fontfiles = { } ( status , output ) = commands . getstatusoutput ( 'fc-list file' ) if ( status == 0 ) : for line in output . split ( '\n' ) : fname = line . split ( ':' ) [ 0 ] if ( ( os . path . splitext ( fname ) [ 1 ] [ 1 : ] in fontext ) and os . path . exists ( fname ) ) : fontfiles [ fname ] = 1 return fontfiles
grab a list of all the fonts that are being tracked by fontconfig by making a system call to fc-list .