Skip to content

Commit 61a35f9

Browse files
authored
Merge pull request #4660 from hugovk/imagedraw-docs
Update ImageDraw docs formatting and links
2 parents 52c66bb + cda682e commit 61a35f9

1 file changed

Lines changed: 49 additions & 50 deletions

File tree

docs/reference/ImageDraw.rst

Lines changed: 49 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ Example: Draw Partial Opacity Text
8181
8282
from PIL import Image, ImageDraw, ImageFont
8383
# get an image
84-
base = Image.open('Pillow/Tests/images/hopper.png').convert('RGBA')
84+
base = Image.open("Pillow/Tests/images/hopper.png").convert("RGBA")
8585
8686
# make a blank image for the text, initialized to transparent text color
87-
txt = Image.new('RGBA', base.size, (255,255,255,0))
87+
txt = Image.new("RGBA", base.size, (255,255,255,0))
8888
8989
# get a font
90-
fnt = ImageFont.truetype('Pillow/Tests/fonts/FreeMono.ttf', 40)
90+
fnt = ImageFont.truetype("Pillow/Tests/fonts/FreeMono.ttf", 40)
9191
# get a drawing context
9292
d = ImageDraw.Draw(txt)
9393
@@ -212,8 +212,8 @@ Methods
212212
.. versionadded:: 1.1.5
213213

214214
.. note:: This option was broken until version 1.1.6.
215-
:param joint: Joint type between a sequence of lines. It can be "curve",
216-
for rounded edges, or None.
215+
:param joint: Joint type between a sequence of lines. It can be ``"curve"``,
216+
for rounded edges, or ``None``.
217217

218218
.. versionadded:: 5.3.0
219219

@@ -280,28 +280,30 @@ Methods
280280

281281
:param xy: Top left corner of the text.
282282
:param text: Text to be drawn. If it contains any newline characters,
283-
the text is passed on to multiline_text()
283+
the text is passed on to
284+
:py:meth:`~PIL.ImageDraw.ImageDraw.multiline_text`.
284285
:param fill: Color to use for the text.
285286
:param font: An :py:class:`~PIL.ImageFont.ImageFont` instance.
286-
:param spacing: If the text is passed on to multiline_text(),
287+
:param spacing: If the text is passed on to
288+
:py:meth:`~PIL.ImageDraw.ImageDraw.multiline_text`,
287289
the number of pixels between lines.
288-
:param align: If the text is passed on to multiline_text(),
289-
"left", "center" or "right".
290-
:param direction: Direction of the text. It can be 'rtl' (right to
291-
left), 'ltr' (left to right) or 'ttb' (top to bottom).
290+
:param align: If the text is passed on to
291+
:py:meth:`~PIL.ImageDraw.ImageDraw.multiline_text`,
292+
``"left"``, ``"center"`` or ``"right"``.
293+
:param direction: Direction of the text. It can be ``"rtl"`` (right to
294+
left), ``"ltr"`` (left to right) or ``"ttb"`` (top to bottom).
292295
Requires libraqm.
293296

294297
.. versionadded:: 4.2.0
295298

296299
:param features: A list of OpenType font features to be used during text
297300
layout. This is usually used to turn on optional
298301
font features that are not enabled by default,
299-
for example 'dlig' or 'ss01', but can be also
300-
used to turn off default font features for
301-
example '-liga' to disable ligatures or '-kern'
302+
for example ``"dlig"`` or ``"ss01"``, but can be also
303+
used to turn off default font features, for
304+
example ``"-liga"`` to disable ligatures or ``"-kern"``
302305
to disable kerning. To get all supported
303-
features, see
304-
https://docs.microsoft.com/en-us/typography/opentype/spec/featurelist
306+
features, see `OpenType docs`_.
305307
Requires libraqm.
306308

307309
.. versionadded:: 4.2.0
@@ -310,8 +312,7 @@ Methods
310312
different glyph shapes or ligatures. This parameter tells
311313
the font which language the text is in, and to apply the
312314
correct substitutions as appropriate, if available.
313-
It should be a `BCP 47 language code
314-
<https://www.w3.org/International/articles/language-tags/>`
315+
It should be a `BCP 47 language code`_.
315316
Requires libraqm.
316317

317318
.. versionadded:: 6.0.0
@@ -321,9 +322,9 @@ Methods
321322
.. versionadded:: 6.2.0
322323

323324
:param stroke_fill: Color to use for the text stroke. If not given, will default to
324-
the ``fill`` parameter.
325+
the ``fill`` parameter.
325326

326-
.. versionadded:: 6.2.0
327+
.. versionadded:: 6.2.0
327328

328329
.. py:method:: PIL.ImageDraw.ImageDraw.multiline_text(xy, text, fill=None, font=None, anchor=None, spacing=4, align="left", direction=None, features=None, language=None)
329330
@@ -334,22 +335,21 @@ Methods
334335
:param fill: Color to use for the text.
335336
:param font: An :py:class:`~PIL.ImageFont.ImageFont` instance.
336337
:param spacing: The number of pixels between lines.
337-
:param align: "left", "center" or "right".
338-
:param direction: Direction of the text. It can be 'rtl' (right to
339-
left), 'ltr' (left to right) or 'ttb' (top to bottom).
338+
:param align: ``"left"``, ``"center"`` or ``"right"``.
339+
:param direction: Direction of the text. It can be ``"rtl"`` (right to
340+
left), ``"ltr"`` (left to right) or ``"ttb"`` (top to bottom).
340341
Requires libraqm.
341342

342343
.. versionadded:: 4.2.0
343344

344345
:param features: A list of OpenType font features to be used during text
345346
layout. This is usually used to turn on optional
346347
font features that are not enabled by default,
347-
for example 'dlig' or 'ss01', but can be also
348-
used to turn off default font features for
349-
example '-liga' to disable ligatures or '-kern'
348+
for example ``"dlig"`` or ``"ss01"``, but can be also
349+
used to turn off default font features, for
350+
example ``"-liga"`` to disable ligatures or ``"-kern"``
350351
to disable kerning. To get all supported
351-
features, see
352-
https://docs.microsoft.com/en-us/typography/opentype/spec/featurelist
352+
features, see `OpenType docs`_.
353353
Requires libraqm.
354354

355355
.. versionadded:: 4.2.0
@@ -358,8 +358,7 @@ Methods
358358
different glyph shapes or ligatures. This parameter tells
359359
the font which language the text is in, and to apply the
360360
correct substitutions as appropriate, if available.
361-
It should be a `BCP 47 language code
362-
<https://www.w3.org/International/articles/language-tags/>`
361+
It should be a `BCP 47 language code`_.
363362
Requires libraqm.
364363

365364
.. versionadded:: 6.0.0
@@ -369,33 +368,32 @@ Methods
369368
Return the size of the given string, in pixels.
370369

371370
:param text: Text to be measured. If it contains any newline characters,
372-
the text is passed on to multiline_textsize()
371+
the text is passed on to :py:meth:`~PIL.ImageDraw.ImageDraw.multiline_textsize`.
373372
:param font: An :py:class:`~PIL.ImageFont.ImageFont` instance.
374-
:param spacing: If the text is passed on to multiline_textsize(),
373+
:param spacing: If the text is passed on to
374+
:py:meth:`~PIL.ImageDraw.ImageDraw.multiline_textsize`,
375375
the number of pixels between lines.
376-
:param direction: Direction of the text. It can be 'rtl' (right to
377-
left), 'ltr' (left to right) or 'ttb' (top to bottom).
376+
:param direction: Direction of the text. It can be ``"rtl"`` (right to
377+
left), ``"ltr"`` (left to right) or ``"ttb"`` (top to bottom).
378378
Requires libraqm.
379379

380380
.. versionadded:: 4.2.0
381381
:param features: A list of OpenType font features to be used during text
382382
layout. This is usually used to turn on optional
383383
font features that are not enabled by default,
384-
for example 'dlig' or 'ss01', but can be also
385-
used to turn off default font features for
386-
example '-liga' to disable ligatures or '-kern'
384+
for example ``"dlig"`` or ``"ss01"``, but can be also
385+
used to turn off default font features, for
386+
example ``"-liga"`` to disable ligatures or ``"-kern"``
387387
to disable kerning. To get all supported
388-
features, see
389-
https://docs.microsoft.com/en-us/typography/opentype/spec/featurelist
388+
features, see `OpenType docs`_.
390389
Requires libraqm.
391390

392391
.. versionadded:: 4.2.0
393392
:param language: Language of the text. Different languages may use
394393
different glyph shapes or ligatures. This parameter tells
395394
the font which language the text is in, and to apply the
396395
correct substitutions as appropriate, if available.
397-
It should be a `BCP 47 language code
398-
<https://www.w3.org/International/articles/language-tags/>`
396+
It should be a `BCP 47 language code`_.
399397
Requires libraqm.
400398

401399
.. versionadded:: 6.0.0
@@ -411,21 +409,20 @@ Methods
411409
:param text: Text to be measured.
412410
:param font: An :py:class:`~PIL.ImageFont.ImageFont` instance.
413411
:param spacing: The number of pixels between lines.
414-
:param direction: Direction of the text. It can be 'rtl' (right to
415-
left), 'ltr' (left to right) or 'ttb' (top to bottom).
412+
:param direction: Direction of the text. It can be ``"rtl"`` (right to
413+
left), ``"ltr"`` (left to right) or ``"ttb"`` (top to bottom).
416414
Requires libraqm.
417415

418416
.. versionadded:: 4.2.0
419417

420418
:param features: A list of OpenType font features to be used during text
421419
layout. This is usually used to turn on optional
422420
font features that are not enabled by default,
423-
for example 'dlig' or 'ss01', but can be also
424-
used to turn off default font features for
425-
example '-liga' to disable ligatures or '-kern'
421+
for example ``"dlig"`` or ``"ss01"``, but can be also
422+
used to turn off default font features, for
423+
example ``"-liga"`` to disable ligatures or ``"-kern"``
426424
to disable kerning. To get all supported
427-
features, see
428-
https://docs.microsoft.com/en-us/typography/opentype/spec/featurelist
425+
features, see `OpenType docs`_.
429426
Requires libraqm.
430427

431428
.. versionadded:: 4.2.0
@@ -434,8 +431,7 @@ Methods
434431
different glyph shapes or ligatures. This parameter tells
435432
the font which language the text is in, and to apply the
436433
correct substitutions as appropriate, if available.
437-
It should be a `BCP 47 language code
438-
<https://www.w3.org/International/articles/language-tags/>`
434+
It should be a `BCP 47 language code`_.
439435
Requires libraqm.
440436

441437
.. versionadded:: 6.0.0
@@ -472,3 +468,6 @@ Methods
472468
tolerable difference of a pixel value from the 'background' in
473469
order for it to be replaced. Useful for filling regions of non-
474470
homogeneous, but similar, colors.
471+
472+
.. _BCP 47 language code: https://www.w3.org/International/articles/language-tags/
473+
.. _OpenType docs: https://docs.microsoft.com/en-us/typography/opentype/spec/featurelist

0 commit comments

Comments
 (0)