PIL uses its own font file format to store bitmap fonts. You can use the utility: command’pilfont’ to convert BDF and PCF font descriptors (X Window font formats) to this format.
PIL.ImageFont.truetype ()
Download a TrueType or OpenType font file and create a font object. This function loads a font object from the specified file and creates a font object for the font of the specified size.
This function requires the the _imagingft
service.
Syntax: PIL.ImageFont.truetype (font = None, size = 10, index = 0, encoding = ”)
Parameters :
font - 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).Returns : A font object.
Exception : IOError - If the file could not be read.
Used image:
|
Output:
Another example: take another image.
Image is being used
|
Output: