The ImageFont Module

The ImageFont module defines a class with the same name. Instances of this class store bitmap fonts, and are used with the text method in 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.

Functions

load (factory)

load(file). Loads a font from the given file, and returns the corresponding font object. If this function fails, it raises an IOError exception.

load_path (factory)

load_path(file). Same as load, but searches for the file along sys.path if it's not found in the current directory.

Methods

getsize

getsize(text). Returns the width and height of the given text, as a 2-tuple.

getmask

getmask(text). Returns a bitmap for the text. The bitmap should be an internal PIL storage memory instance (as defined by the _imaging interface module).

If the font uses antialiasing, the bitmap should have mode "L" and use a maximum value of 255. Otherwise, it should have mode "1".