@header@
 
 
matplotlib.font_manager
index
/usr/lib64/python2.4/site-packages/matplotlib/font_manager.py

A module for finding, managing, and using fonts across-platforms.
 
This module provides a single FontManager that can be shared across
backends and platforms.  The findfont() method returns the best
TrueType (TTF) font file in the local or system font path that matches
the specified FontProperties.  The FontManager also handles Adobe Font
Metrics (AFM) font files for use by the PostScript backend.
 
The design is based on the W3C Cascading Style Sheet, Level 1 (CSS1)
font specification (http://www.w3.org/TR/1998/REC-CSS2-19980512/ ).
Future versions may implement the Level 2 or 2.1 specifications.
 
 
KNOWN ISSUES
 
  - documentation
  - font variant is untested
  - font stretch is incomplete
  - font size is incomplete
  - font size_adjust is incomplete
  - default font algorithm needs improvement and testing
  - setWeights function needs improvement
  - 'light' is an invalid weight value, remove it.
  - update_fonts not implemented
 
 
Authors   : John Hunter <jdhunter@ace.bsd.uchicago.edu>
            Paul Barrett <Barrett@STScI.Edu>
Copyright : John Hunter (2004,2005), Paul Barrett (2004,2005)
License   : matplotlib license (PSF compatible)
            The font directory code is from ttfquery,
            see license/LICENSE_TTFQUERY.

 
Modules
       
matplotlib.afm
matplotlib.ft2font
glob
matplotlib
os
shutil
sys
warnings

 
Classes
       
__builtin__.object
FontKey
FontManager
FontProperties

 
class FontKey(__builtin__.object)
    A class for storing Font properties.  It is used when populating
the font dictionary.
 
  Methods defined here:
__init__(self, name='', style='normal', variant='normal', weight='normal', stretch='normal', size='medium')

Data and other attributes defined here:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'FontKey' objects>
list of weak references to the object (if defined)

 
class FontManager
    On import, the FontManager creates a dictionary of TrueType
fonts based on the font properties: name, style, variant, weight,
stretch, and size.  The findfont() method searches this dictionary
for a font file name that exactly matches the font properties of the
specified text.  If none is found, a default font is returned.  By
updating the dictionary with the properties of the found font, the
font dictionary can act like a font cache.
 
  Methods defined here:
__init__(self, size=None, weight='normal')
findfont(self, prop, fontext='ttf')
Search the font dictionary for a font that exactly or closely
matches the specified font properties.  See the FontProperties class
for a description.
 
The properties are searched in the following order: name, style,
variant, weight, stretch, and size.  The font weight always matches
returning the closest weight, and the font size always matches for
scalable fonts.  An oblique style font will be used inplace of a
missing italic style font if present.  See the W3C Cascading Style
Sheet, Level 1 (CSS1; http://www.w3.org/TR/1998/REC-CSS2-19980512/)
documentation for a description of the font finding algorithm.
get_default_size(self)
Return the default font size.
get_default_weight(self)
Return the default font weight.
set_default_size(self, size)
Set the default font size in points.  The initial value is set by font.size in rc.
set_default_weight(self, weight)
Set the default font weight.  The initial value is 'normal'.
update_fonts(self, filenames)
Update the font dictionary with new font files.
Currently not implemented.

 
class FontProperties
    A class for storing and manipulating font properties.
 
The font properties are those described in the W3C Cascading Style
Sheet, Level 1 (CSS1; http://www.w3.org/TR/1998/REC-CSS2-19980512/)
font specification.  The six properties are:
 
  family  - A list of font names in decreasing order of priority.
            The last item is the default font name and is given the
            name of the font family, either serif, sans-serif,
            cursive, fantasy, and monospace.
  style   - Either normal, italic or oblique.
  variant - Either normal or small-caps.
  stretch - Either an absolute value of ultra-condensed, extra-
            condensed, condensed, semi-condensed, normal, semi-
            expanded, expanded, extra-expanded or ultra-expanded;
            or a relative value of narrower or wider.
            This property is currently not implemented and is set to
            normal.
  weight  - A numeric value in the range 100, 200, 300, ..., 900.
  size    - Either an absolute value of xx-small, x-small, small,
            medium, large, x-large, xx-large; or a relative value
            of smaller or larger; or an absolute font size, e.g. 12;
            or scalable.
 
The default font property for TrueType fonts is: sans-serif, normal,
normal, normal, 400, scalable.
 
The preferred usage of font sizes is to use the absolute values, e.g.
large, instead of absolute font sizes, e.g. 12.  This approach allows
all text sizes to be made larger or smaller based on the font manager's
default font size, i.e. by using the set_default_size() method of the
font manager.
 
 
Examples:
 
  #  Load default font properties
  >>> p = FontProperties()
  >>> p.get_family()
  ['Bitstream Vera Sans', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucida', 'Arial', 'Helvetica', 'sans-serif']
 
  #  Change font family to 'fantasy'
  >>> p.set_family('fantasy')
  >>> p.get_family()
  ['Comic Sans MS', 'Chicago', 'Charcoal', 'Impact', 'Western', 'fantasy']
 
  #  Make these fonts highest priority in font family
  >>> p.set_name(['foo', 'fantasy', 'bar', 'baz'])
  Font name 'fantasy' is a font family. It is being deleted from the list.
  >>> p.get_family()
  ['foo', 'bar', 'baz', 'Comic Sans MS', 'Chicago', 'Charcoal', 'Impact', 'Western', 'fantasy']
 
  Methods defined here:
__hash__(self)
__init__(self, family=None, style=None, variant=None, weight=None, stretch=None, size=None, fname=None)
__str__(self)
copy(self)
Return a deep copy of self
get_family(self)
Return a list of font names that comprise the font family.
get_name(self)
Return the name of the font that best matches the font
properties.
get_size(self)
Return the font size.
get_size_in_points(self, parent_size=None)
Return the size property as a numeric value.  String values
are converted to their corresponding numeric value.
get_stretch(self)
Return the font stretch or width.  Options are: normal,
narrow, condensed, or wide.
get_style(self)
Return the font style.  Values are: normal, italic or oblique.
get_variant(self)
Return the font variant.  Values are: normal or small-caps.
get_weight(self)
Return the font weight.  See the FontProperties class for a
a list of possible values.
set_family(self, family)
Change the font family.  Options are: serif, sans-serif, cursive,
fantasy, or monospace.
set_name(self, names)
Add one or more font names to the font family list.  If the
font name is already in the list, then the font is given a higher
priority in the font family list.  To change the font family, use the
set_family() method.
set_size(self, size)
Set the font size.
set_stretch(self, stretch)
Set the font stretch or width.  Options are: normal, narrow,
condensed, or wide.
set_style(self, style)
Set the font style.  Values are: normal, italic or oblique.
set_variant(self, variant)
Set the font variant.  Values are: normal or small-caps.
set_weight(self, weight)
Set the font weight.  See the FontProperties class for a
a list of possible values.

 
Functions
       
OSXFontDirectory()
Return the system font directories for OS X.
OSXInstalledFonts(directory=None, fontext=None)
Get list of font files on OS X - ignores font suffix by default
add_filename(fontdict, prop, fname)
A function to add a font file name to the font dictionary using
the FontKey properties.  If a font property has no dictionary, then
create it.
afmFontProperty(font)
A function for populating the FontKey by extracting information
from the AFM font file.
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.
findSystemFonts(fontpaths=None, fontext='ttf')
Search for fonts in the specified font paths, or use the system
paths if none given.  A list of TrueType fonts are returned by default
with AFM fonts as an option.
setWeights(font)
A function to populate missing values in a font weight
dictionary.  This proceedure is necessary since the font finding
algorithm always matches on the weight property.
ttfFontProperty(font)
A function for populating the FontKey by extracting information
from the TrueType font file.
ttfdict_to_fnames(d)
flatten a ttfdict to all the filenames it contains
weight_as_number(weight)
Return the weight property as a numeric value.  String values
are converted to their corresponding numeric value.
win32FontDirectory()
Return the user-specified font directory for Win32.
win32InstalledFonts(directory=None, fontext='ttf')
Search for fonts in the specified font directory, or use the
system directories if none given.  A list of TrueType fonts are
returned by default with AFM fonts as an option.
x11FontDirectory()
Return the system font directories for X11.

 
Data
        MSFolders = r'Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders'
MSFontDirectories = [r'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts', r'SOFTWARE\Microsoft\Windows\CurrentVersion\Fonts']
OSXFontDirectories = ['/Library/Fonts/', '/Network/Library/Fonts/', '/System/Library/Fonts/', '/home/darren/Library/Fonts']
X11FontDirectories = ['/usr/X11R6/lib/X11/fonts/TTF/', '/usr/share/fonts/', '/usr/local/share/fonts/', '/usr/lib/openoffice/share/fonts/truetype/']
fontManager = <matplotlib.font_manager.FontManager instance>
font_scalings = {'large': 1.2, 'medium': 1.0, 'small': 0.83299999999999996, 'x-large': 1.4399999999999999, 'x-small': 0.69399999999999995, 'xx-large': 1.728, 'xx-small': 0.57899999999999996}
home = '/home/darren'
path = '/home/darren/Library/Fonts'
rcParams = {'axes.axisbelow': False, 'axes.edgecolor': 'k', 'axes.facecolor': 'w', 'axes.formatter.limits': (-7, 7), 'axes.grid': False, 'axes.hold': True, 'axes.labelcolor': 'k', 'axes.labelsize': 'medium', 'axes.linewidth': 1.0, 'axes.titlesize': 'medium', ...}
verbose = <matplotlib.Verbose instance>
weight_dict = {'black': 900, 'bold': 700, 'book': 400, 'demi': 600, 'demibold': 600, 'extra bold': 800, 'heavy': 800, 'light': 200, 'medium': 500, 'normal': 400, ...}
@footer@