Skip to content

Commit 8135bd5

Browse files
committed
Added documentation
1 parent 04d9761 commit 8135bd5

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

docs/reference/ImageDraw.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Fonts
6464

6565
PIL can use bitmap fonts or OpenType/TrueType fonts.
6666

67-
Bitmap fonts are stored in PILs own format, where each font typically consists
67+
Bitmap fonts are stored in PIL's own format, where each font typically consists
6868
of two files, one named .pil and the other usually named .pbm. The former
6969
contains font metrics, the latter raster data.
7070

@@ -146,6 +146,11 @@ Methods
146146
147147
Get the current default font.
148148

149+
To set the default font for all future ImageDraw instances::
150+
151+
from PIL import ImageDraw, ImageFont
152+
ImageDraw.ImageDraw.font = ImageFont.truetype("Tests/fonts/FreeMono.ttf")
153+
149154
:returns: An image font.
150155

151156
.. py:method:: ImageDraw.arc(xy, start, end, fill=None, width=0)

docs/releasenotes/9.3.0.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ TODO
2626
API Additions
2727
=============
2828

29+
Allow default ImageDraw font to be set
30+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
31+
32+
Rather than specifying a font when calling text-related ImageDraw methods, or
33+
setting a font on each ImageDraw instance, the default font can now be set for
34+
all future ImageDraw operations.
35+
36+
from PIL import ImageDraw, ImageFont
37+
ImageDraw.ImageDraw.font = ImageFont.truetype("Tests/fonts/FreeMono.ttf")
38+
2939
Saving multiple MPO frames
3040
^^^^^^^^^^^^^^^^^^^^^^^^^^
3141

src/PIL/ImageDraw.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ def getfont(self):
9393
"""
9494
Get the current default font.
9595
96+
To set the default font for all future ImageDraw instances::
97+
98+
from PIL import ImageDraw, ImageFont
99+
ImageDraw.ImageDraw.font = ImageFont.truetype("Tests/fonts/FreeMono.ttf")
100+
96101
:returns: An image font."""
97102
if not self.font:
98103
# FIXME: should add a font repository

0 commit comments

Comments
 (0)