Skip to content

Commit 97280a0

Browse files
authored
Merge pull request #4548 from radarhere/multiline_text
Added multiline text example
2 parents 27e8592 + b2f187c commit 97280a0

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

docs/reference/ImageDraw.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,25 @@ Example: Draw Partial Opacity Text
100100
101101
out.show()
102102
103+
Example: Draw Multiline Text
104+
----------------------------
105+
106+
.. code-block:: python
107+
108+
from PIL import Image, ImageDraw, ImageFont
109+
110+
# create an image
111+
out = Image.new("RGB", (150, 100), (255, 255, 255))
112+
113+
# get a font
114+
fnt = ImageFont.truetype("Pillow/Tests/fonts/FreeMono.ttf", 40)
115+
# get a drawing context
116+
d = ImageDraw.Draw(out)
117+
118+
# draw multiline text
119+
d.multiline_text((10,10), "Hello\nWorld", font=fnt, fill=(0, 0, 0))
120+
121+
out.show()
103122
104123
105124
Functions

0 commit comments

Comments
 (0)