PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. The
ImageFont module defines a class with the same name. Instances of this class store bitmap fonts, and are used with the
PIL uses its own font file format to store bitmap fonts. You can use the :command`pilfont` utility to convert BDF and PCF font descriptors (X window font formats) to this format.
PIL.ImageFont.truetype() 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.
Syntax: PIL.ImageFont.truetype(font=None, size=10, index=0, encoding=”)
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.
Another example:Take another image.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course