Pillow/docs/reference/ImageFont.rst

58 lines
1.4 KiB
ReStructuredText
Raw Normal View History

2013-10-13 04:14:12 +04:00
.. py:module:: PIL.ImageFont
.. py:currentmodule:: PIL.ImageFont
:py:mod:`ImageFont` Module
==========================
2013-10-13 04:14:12 +04:00
The :py:mod:`ImageFont` module defines a class with the same name. Instances of
this class store bitmap fonts, and are used with the
:py:meth:`PIL.ImageDraw.Draw.text` method.
PIL uses its own font file format to store bitmap fonts. You can use the
2017-04-05 00:10:22 +03:00
:command:`pilfont` utility to convert BDF and PCF font descriptors (X window
2013-10-13 04:14:12 +04:00
font formats) to this format.
Starting with version 1.1.4, PIL can be configured to support TrueType and
OpenType fonts (as well as other font formats supported by the FreeType
library). For earlier versions, TrueType support is only available as part of
the imToolkit package
Example
-------
.. code-block:: python
from PIL import ImageFont, ImageDraw
draw = ImageDraw.Draw(image)
# use a bitmap font
font = ImageFont.load("arial.pil")
draw.text((10, 10), "hello", font=font)
# use a truetype font
font = ImageFont.truetype("arial.ttf", 15)
draw.text((10, 25), "world", font=font)
Functions
---------
.. autofunction:: PIL.ImageFont.load
.. autofunction:: PIL.ImageFont.load_path
.. autofunction:: PIL.ImageFont.truetype
.. autofunction:: PIL.ImageFont.load_default
Methods
-------
2019-07-07 13:52:30 +03:00
.. autoclass:: PIL.ImageFont.ImageFont
:members:
2019-04-21 16:27:31 +03:00
.. autoclass:: PIL.ImageFont.FreeTypeFont
2019-04-21 16:28:08 +03:00
:members:
2019-07-07 13:52:30 +03:00
.. autoclass:: PIL.ImageFont.TransposedFont
:members: