Personal tools
You are here: Home Zpydoc API documentation matplotlib.font_manager

 matplotlib.font_manager  

Up one level
matplotlib font_manager
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() function 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.
Packages
matplotlib
Modules
matplotlib.afm matplotlib.ft2font
Classes
  class FontKey ( object )
A class for storing Font properties. It is used when populating the font dictionary.
  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.
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 ( object )
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 relative 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. This class will also accept a fontconfig pattern, if it is the only argument provided. fontconfig patterns are described here: http://www.fontconfig.org/fontconfig-user.html Note that matplotlib's internal font manager and fontconfig use a different algorithm to lookup fonts, so the results of the same pattern may be different in matplotlib than in other applications that use fontconfig.
copy(self)
Return a deep copy of self
get_family(self)
Return a list of font names that comprise the font family.
get_file(self)
get_fontconfig_pattern(self)
get_name(self)
Return the name of the font that best matches the font properties.
get_size(self)
Return the font size.
get_size(self)
Return the font size.
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. May be either an alias (generic name is CSS parlance), such as: serif, sans-serif, cursive, fantasy, or monospace, or a real font name.
set_file(self, file)
set_fontconfig_pattern(self, pattern)
set_family(self, family)
Change the font family. May be either an alias (generic name is CSS parlance), such as: serif, sans-serif, cursive, fantasy, or monospace, or a real font name.
set_size(self, size)
Set the font size.
set_style(self, style)
Set the font style. Values are: normal, italic or oblique.
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='ttf')
Get list of font files on OS X - ignores font suffix by default
_rebuild ()
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. 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.
findfont (prop, **kw)
generate_fontconfig_pattern (d)
Given a dictionary of key/value pairs, generates a fontconfig pattern string.
wrapper (*args, **kwargs)
Return the string representing the configuration dir. default is HOME/.matplotlib. you can override this with the MPLCONFIGDIR environment variable
get_fontconfig_fonts (fontext='ttf')
Grab a list of all the fonts that are being tracked by fontconfig. This is an easy way to grab all of the fonts the user wants to be made available to applications, without knowing where all of them reside.
get_fontext_synonyms (fontext)
is_opentype_cff_font (filename)
Returns True if the given font is a Postscript Compact Font Format Font embedded in an OpenType wrapper.
is_string_like (obj)
return true if *obj* looks like a string
pickle_dump (data, filename)
Equivalent to pickle.dump(data, open(filename, 'w')) but closes the file to prevent filehandle leakage.
pickle_load (filename)
Equivalent to pickle.load(open(filename, 'r')) but closes the file to prevent filehandle leakage.
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.
Document Actions
« September 2010 »
September
MoTuWeThFrSaSu
12345
6789101112
13141516171819
20212223242526
27282930
Log in


Forgot your password?
New user?