Added documentation

This commit is contained in:
Andrew Murray 2022-08-11 10:35:44 +10:00
parent 04d9761316
commit 8135bd5cfb
3 changed files with 21 additions and 1 deletions

View File

@ -64,7 +64,7 @@ Fonts
PIL can use bitmap fonts or OpenType/TrueType fonts.
Bitmap fonts are stored in PILs own format, where each font typically consists
Bitmap fonts are stored in PIL's own format, where each font typically consists
of two files, one named .pil and the other usually named .pbm. The former
contains font metrics, the latter raster data.
@ -146,6 +146,11 @@ Methods
Get the current default font.
To set the default font for all future ImageDraw instances::
from PIL import ImageDraw, ImageFont
ImageDraw.ImageDraw.font = ImageFont.truetype("Tests/fonts/FreeMono.ttf")
:returns: An image font.
.. py:method:: ImageDraw.arc(xy, start, end, fill=None, width=0)

View File

@ -26,6 +26,16 @@ TODO
API Additions
=============
Allow default ImageDraw font to be set
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Rather than specifying a font when calling text-related ImageDraw methods, or
setting a font on each ImageDraw instance, the default font can now be set for
all future ImageDraw operations.
from PIL import ImageDraw, ImageFont
ImageDraw.ImageDraw.font = ImageFont.truetype("Tests/fonts/FreeMono.ttf")
Saving multiple MPO frames
^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -93,6 +93,11 @@ class ImageDraw:
"""
Get the current default font.
To set the default font for all future ImageDraw instances::
from PIL import ImageDraw, ImageFont
ImageDraw.ImageDraw.font = ImageFont.truetype("Tests/fonts/FreeMono.ttf")
:returns: An image font."""
if not self.font:
# FIXME: should add a font repository