Logo Search packages:      
Sourcecode: matplotlib version File versions

def matplotlib::font_manager::createFontDict (   fontfiles,
  fontext = 'ttf' 
)

A function to create a dictionary of font file paths.  The
default is to create a dictionary for TrueType fonts.  An AFM font
dictionary can optionally be created.

Definition at line 489 of file font_manager.py.

00489                                             :
    """
    A function to create a dictionary of font file paths.  The
    default is to create a dictionary for TrueType fonts.  An AFM font
    dictionary can optionally be created.
    """

    fontdict = {}
    #  Add fonts from list of known font files.
    seen = {}
    for fpath in fontfiles:
        verbose.report('createFontDict: %s' % (fpath), 'debug')
        fname = os.path.split(fpath)[1]
        if seen.has_key(fname):  continue
        else: seen[fname] = 1
        if fontext == 'afm':
            try:
                fh = open(fpath, 'r')
            except:
                verbose.report("Could not open font file %s" % fpath)
                continue
            try:
                try:
                    font = afm.AFM(fh)
                finally:
                    fh.close()
            except RuntimeError:
                verbose.report("Could not parse font file %s"%fpath)
                continue
            prop = afmFontProperty(font)
        else:
            try:
                font = ft2font.FT2Font(str(fpath))
            except RuntimeError:
                verbose.report("Could not open font file %s"%fpath)
                continue
            except UnicodeError:
                verbose.report("Cannot handle unicode filenames")
                #print >> sys.stderr, 'Bad file is', fpath
                continue
            try: prop = ttfFontProperty(font)
            except: continue

        add_filename(fontdict, prop, fpath)
    return fontdict

def setWeights(font):


Generated by  Doxygen 1.6.0   Back to index