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.
- Python | Merge Python key values to list
- Python | Index of Non-Zero elements in Python list
- Python | Convert list to Python array
- Important differences between Python 2.x and Python 3.x with examples
- Reading Python File-Like Objects from C | Python
- Python | Add Logging to Python Libraries
- Python | Add Logging to a Python Script
- Python | Set 4 (Dictionary, Keywords in Python)
- Python | Sort Python Dictionaries by Key or Value
- Python | Visualizing O(n) using Python
- gcd() in Python
- Python | a += b is not always a = a + b
- max() and min() in Python
- zip() in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.