API Reference for Enthought Tool Suite 3.2.0

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, one of: serif, sans-serif, cursive, fantasy, or monospace.
style
One of: normal, italic or oblique.
variant
Either normal or small-caps.
stretch
Either an absolute or relative value. Absolute values are: ultra-condensed, extra-condensed, condensed, semi-condensed, normal, semi-expanded, expanded, extra-expanded or ultra-expanded; relative values are: 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
An absolute or relative value, or an absolute font size, or scalable. Absolute values are: xx-small, x-small, small, medium, large, x-large, xx-large; relative values are smaller or larger.

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']

Method summary

Methods

© Copyright 2002-2009 Enthought, Inc.