Skip to content

Commit dc0c7be

Browse files
committed
Update ImageDraw docs formatting and links
1 parent ba58ae7 commit dc0c7be

1 file changed

Lines changed: 35 additions & 37 deletions

File tree

docs/reference/ImageDraw.rst

Lines changed: 35 additions & 37 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
@@ -280,25 +280,25 @@ 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 ``multiline_text()``
284284
:param fill: Color to use for the text.
285285
:param font: An :py:class:`~PIL.ImageFont.ImageFont` instance.
286-
:param spacing: If the text is passed on to multiline_text(),
286+
:param spacing: If the text is passed on to ``multiline_text()``,
287287
the number of pixels between lines.
288-
:param align: If the text is passed on to multiline_text(),
288+
:param align: If the text is passed on to ``multiline_text()``,
289289
"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 direction: Direction of the text. It can be ``"rtl"`` (right to
291+
left), ``"ltr"`` (left to right) or ``"ttb"`` (top to bottom).
292292
Requires libraqm.
293293

294294
.. versionadded:: 4.2.0
295295

296296
:param features: A list of OpenType font features to be used during text
297297
layout. This is usually used to turn on optional
298298
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'
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"``
302302
to disable kerning. To get all supported
303303
features, see
304304
https://docs.microsoft.com/en-us/typography/opentype/spec/featurelist
@@ -310,8 +310,7 @@ Methods
310310
different glyph shapes or ligatures. This parameter tells
311311
the font which language the text is in, and to apply the
312312
correct substitutions as appropriate, if available.
313-
It should be a `BCP 47 language code
314-
<https://www.w3.org/International/articles/language-tags/>`
313+
It should be a `BCP 47 language code`_.
315314
Requires libraqm.
316315

317316
.. versionadded:: 6.0.0
@@ -334,19 +333,19 @@ Methods
334333
:param fill: Color to use for the text.
335334
:param font: An :py:class:`~PIL.ImageFont.ImageFont` instance.
336335
: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).
336+
:param align: ``"left"``, ``"center"`` or ``"right"``.
337+
:param direction: Direction of the text. It can be ``"rtl"`` (right to
338+
left), ``"ltr"`` (left to right) or ``"ttb"`` (top to bottom).
340339
Requires libraqm.
341340

342341
.. versionadded:: 4.2.0
343342

344343
:param features: A list of OpenType font features to be used during text
345344
layout. This is usually used to turn on optional
346345
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'
346+
for example ``"dlig"`` or ``"ss01"``, but can be also
347+
used to turn off default font features, for
348+
example ``"-liga"`` to disable ligatures or ``"-kern"``
350349
to disable kerning. To get all supported
351350
features, see
352351
https://docs.microsoft.com/en-us/typography/opentype/spec/featurelist
@@ -358,8 +357,7 @@ Methods
358357
different glyph shapes or ligatures. This parameter tells
359358
the font which language the text is in, and to apply the
360359
correct substitutions as appropriate, if available.
361-
It should be a `BCP 47 language code
362-
<https://www.w3.org/International/articles/language-tags/>`
360+
It should be a `BCP 47 language code`_.
363361
Requires libraqm.
364362

365363
.. versionadded:: 6.0.0
@@ -369,21 +367,21 @@ Methods
369367
Return the size of the given string, in pixels.
370368

371369
:param text: Text to be measured. If it contains any newline characters,
372-
the text is passed on to multiline_textsize()
370+
the text is passed on to ``multiline_textsize()``
373371
:param font: An :py:class:`~PIL.ImageFont.ImageFont` instance.
374-
:param spacing: If the text is passed on to multiline_textsize(),
372+
:param spacing: If the text is passed on to ``multiline_textsize()``,
375373
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).
374+
:param direction: Direction of the text. It can be ``"rtl"`` (right to
375+
left), ``"ltr"`` (left to right) or ``"ttb"`` (top to bottom).
378376
Requires libraqm.
379377

380378
.. versionadded:: 4.2.0
381379
:param features: A list of OpenType font features to be used during text
382380
layout. This is usually used to turn on optional
383381
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'
382+
for example ``"dlig"`` or ``"ss01"``, but can be also
383+
used to turn off default font features, for
384+
example ``"-liga"`` to disable ligatures or ``"-kern"``
387385
to disable kerning. To get all supported
388386
features, see
389387
https://docs.microsoft.com/en-us/typography/opentype/spec/featurelist
@@ -394,8 +392,7 @@ Methods
394392
different glyph shapes or ligatures. This parameter tells
395393
the font which language the text is in, and to apply the
396394
correct substitutions as appropriate, if available.
397-
It should be a `BCP 47 language code
398-
<https://www.w3.org/International/articles/language-tags/>`
395+
It should be a `BCP 47 language code`_.
399396
Requires libraqm.
400397

401398
.. versionadded:: 6.0.0
@@ -411,18 +408,18 @@ Methods
411408
:param text: Text to be measured.
412409
:param font: An :py:class:`~PIL.ImageFont.ImageFont` instance.
413410
: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).
411+
:param direction: Direction of the text. It can be ``"rtl"`` (right to
412+
left), ``"ltr"`` (left to right) or ``"ttb"`` (top to bottom).
416413
Requires libraqm.
417414

418415
.. versionadded:: 4.2.0
419416

420417
:param features: A list of OpenType font features to be used during text
421418
layout. This is usually used to turn on optional
422419
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'
420+
for example ``"dlig"`` or ``"ss01"``, but can be also
421+
used to turn off default font features, for
422+
example ``"-liga"`` to disable ligatures or ``"-kern"``
426423
to disable kerning. To get all supported
427424
features, see
428425
https://docs.microsoft.com/en-us/typography/opentype/spec/featurelist
@@ -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,5 @@ 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/

0 commit comments

Comments
 (0)