The PIL.ImageFont Module

FreeTypeFont(file, size, index=0, encoding="") (class) [#]

Wrapper for FreeType fonts.

For more information about this class, see The FreeTypeFont Class.

ImageFont (class) [#]

The ImageFont module defines a class with the same name.

For more information about this class, see The ImageFont Class.

load(filename) [#]

Load font file. This function loads a font object from the given bitmap font file, and returns the corresponding font object.

filename
Name of font file.
Returns:
A font object.
Raises IOError:
If the file could not be read.

load_default() [#]

Load a (probably rather ugly) default font.

Returns:
A font object.

load_path(filename) [#]

Load font file. Same as load, but searches for a bitmap font along the Python path.

filename
Name of font file.
Returns:
A font object.
Raises IOError:
If the file could not be read.

TransposedFont(font, orientation=None) (class) [#]

Wrapper that creates a transposed font from any existing font object.

font
A font object.
orientation
An optional orientation. If given, this should be one of Image.FLIP_LEFT_RIGHT, Image.FLIP_TOP_BOTTOM, Image.ROTATE_90, Image.ROTATE_180, or Image.ROTATE_270.

For more information about this class, see The TransposedFont Class.

truetype(filename, size, index=0, encoding="") [#]

Load a TrueType or OpenType font file, and create a font object. This function loads a font object from the given file, and creates a font object for a font of the given size.

This function requires the _imagingft service.

filename
A truetype font file. Under Windows, if the file is not found in this filename, the loader also looks in Windows fonts directory
size
The requested size, in points.
index
Which font face to load (default is first available face).
encoding
Which font encoding to use (default is Unicode). Common encodings are "unic" (Unicode), "symb" (Microsoft Symbol), "ADOB" (Adobe Standard), "ADBE" (Adobe Expert), and "armn" (Apple Roman). See the FreeType documentation for more information.
Returns:
A font object.
Raises IOError:
If the file could not be read.

The FreeTypeFont Class

FreeTypeFont(file, size, index=0, encoding="") (class) [#]

Wrapper for FreeType fonts. Application code should use the truetype factory function to create font objects.

The ImageFont Class

ImageFont (class) [#]

The ImageFont module defines a class with the same name. Instances of this class store bitmap fonts, and are used with the text method of the ImageDraw class.

PIL uses it's own font file format to store bitmap fonts. You can use the pilfont utility to convert BDF and PCF font descriptors (X window font formats) to this format.

Starting with version 1.1.4, PIL can be configured to support TrueType and OpenType fonts. For earlier version, TrueType support is only available as part of the imToolkit package

The TransposedFont Class

TransposedFont(font, orientation=None) (class) [#]

Wrapper that creates a transposed font from any existing font object.

font
A font object.
orientation
An optional orientation. If given, this should be one of Image.FLIP_LEFT_RIGHT, Image.FLIP_TOP_BOTTOM, Image.ROTATE_90, Image.ROTATE_180, or Image.ROTATE_270.