Documentation for module t1Imaging


Interface for using t1lib-generated bitmaps with Fredrik Lundh's Python Imaging Library.

This module provides alternate classes for FontSetter and Glyph from the t1lib module. These classes, ImagingSetter and ImagingGlyph, are used by instantiating an ImagingSetter instead of a FontSetter object. This works by overriding the FontSetter.newGlyph() method so that it creates ImagingGlyph objects instead of Glyph objects. The ImagingGlyphs have additional methods which support the creation of PIL images. The PIL images available via the additional interface can be used anywhere PIL images can be used.


Exception ConversionError

Raised when a glyph cannot be converted to a PIL image.


Exception DepthError

Raised when a particular bitmap depth is required but not present.

Constructor
required
found
__str__()

Class ImagingSetter

FontSetter extension which can be used to derive PIL images.

Constructor

Ensure that we don't have to deal with 16-bit bitmaps later.

font
size
angle = 0.0
spaceoff = 0.0
kerning = 0
bpp = 1
newGlyph()

Create a glyph which can be converted to a PIL image.

bits
metrics
bpp

The arguments match those of t1lib.FontSetter.newGlyph().

get32BitMode()

Return the conversion mode for 32-bit images.

set32BitMode()

Set the conversion mode for 32-bit images.

mode
mode indicator; must be 'RGB' or 'RGBA'

Glyphs 32 bits deep can be converted to RGB or RGBA images.

getmask()

Rasterize a string.

string
the string to be rendered

This is provided to support the ImageDraw class from the Python Imaging Library. This interface allows ImageSetter instances which generate glyphs of 1 bit per pixel to be passed to the ImageDraw.setfont() method.

If the bits-per-pixel for generated glyphs is not 1, DepthError is raised.


Class ImagingGlyph

A rasterized image which is also a PIL image.


Functions

test()

Run a stand-alone test.

This function parses the command line. It provides a limited self-test for this module.


Documentation for module t1Imaging