Skip to content

Commit 4c7eeec

Browse files
authored
Merge pull request #7600 from nulano/anchor-clarify-docs
Clarify default anchor alignment
2 parents dfc9e98 + af2d976 commit 4c7eeec

File tree

2 files changed

+25
-18
lines changed

2 files changed

+25
-18
lines changed

docs/reference/ImageDraw.rst

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -362,9 +362,10 @@ Methods
362362
:param fill: Color to use for the text.
363363
:param font: An :py:class:`~PIL.ImageFont.ImageFont` instance.
364364
:param anchor: The text anchor alignment. Determines the relative location of
365-
the anchor to the text. The default alignment is top left.
366-
See :ref:`text-anchors` for valid values. This parameter is
367-
ignored for non-TrueType fonts.
365+
the anchor to the text. The default alignment is top left,
366+
specifically ``la`` for horizontal text and ``lt`` for
367+
vertical text. See :ref:`text-anchors` for details.
368+
This parameter is ignored for non-TrueType fonts.
368369

369370
.. note:: This parameter was present in earlier versions
370371
of Pillow, but implemented only in version 8.0.0.
@@ -433,9 +434,10 @@ Methods
433434
:param font: An :py:class:`~PIL.ImageFont.ImageFont` instance.
434435

435436
:param anchor: The text anchor alignment. Determines the relative location of
436-
the anchor to the text. The default alignment is top left.
437-
See :ref:`text-anchors` for valid values. This parameter is
438-
ignored for non-TrueType fonts.
437+
the anchor to the text. The default alignment is top left,
438+
specifically ``la`` for horizontal text and ``lt`` for
439+
vertical text. See :ref:`text-anchors` for details.
440+
This parameter is ignored for non-TrueType fonts.
439441

440442
.. note:: This parameter was present in earlier versions
441443
of Pillow, but implemented only in version 8.0.0.
@@ -576,9 +578,10 @@ Methods
576578
:py:meth:`~PIL.ImageDraw.ImageDraw.multiline_textbbox`.
577579
:param font: A :py:class:`~PIL.ImageFont.FreeTypeFont` instance.
578580
:param anchor: The text anchor alignment. Determines the relative location of
579-
the anchor to the text. The default alignment is top left.
580-
See :ref:`text-anchors` for valid values. This parameter is
581-
ignored for non-TrueType fonts.
581+
the anchor to the text. The default alignment is top left,
582+
specifically ``la`` for horizontal text and ``lt`` for
583+
vertical text. See :ref:`text-anchors` for details.
584+
This parameter is ignored for non-TrueType fonts.
582585
:param spacing: If the text is passed on to
583586
:py:meth:`~PIL.ImageDraw.ImageDraw.multiline_textbbox`,
584587
the number of pixels between lines.
@@ -630,9 +633,10 @@ Methods
630633
:param text: Text to be measured.
631634
:param font: A :py:class:`~PIL.ImageFont.FreeTypeFont` instance.
632635
:param anchor: The text anchor alignment. Determines the relative location of
633-
the anchor to the text. The default alignment is top left.
634-
See :ref:`text-anchors` for valid values. This parameter is
635-
ignored for non-TrueType fonts.
636+
the anchor to the text. The default alignment is top left,
637+
specifically ``la`` for horizontal text and ``lt`` for
638+
vertical text. See :ref:`text-anchors` for details.
639+
This parameter is ignored for non-TrueType fonts.
636640
:param spacing: The number of pixels between lines.
637641
:param align: ``"left"``, ``"center"`` or ``"right"``. Determines the relative alignment of lines.
638642
Use the ``anchor`` parameter to specify the alignment to ``xy``.

src/PIL/ImageFont.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,9 @@ def getbbox(
392392
:param stroke_width: The width of the text stroke.
393393
394394
:param anchor: The text anchor alignment. Determines the relative location of
395-
the anchor to the text. The default alignment is top left.
396-
See :ref:`text-anchors` for valid values.
395+
the anchor to the text. The default alignment is top left,
396+
specifically ``la`` for horizontal text and ``lt`` for
397+
vertical text. See :ref:`text-anchors` for details.
397398
398399
:return: ``(left, top, right, bottom)`` bounding box
399400
"""
@@ -466,8 +467,9 @@ def getmask(
466467
.. versionadded:: 6.2.0
467468
468469
:param anchor: The text anchor alignment. Determines the relative location of
469-
the anchor to the text. The default alignment is top left.
470-
See :ref:`text-anchors` for valid values.
470+
the anchor to the text. The default alignment is top left,
471+
specifically ``la`` for horizontal text and ``lt`` for
472+
vertical text. See :ref:`text-anchors` for details.
471473
472474
.. versionadded:: 8.0.0
473475
@@ -558,8 +560,9 @@ def getmask2(
558560
.. versionadded:: 6.2.0
559561
560562
:param anchor: The text anchor alignment. Determines the relative location of
561-
the anchor to the text. The default alignment is top left.
562-
See :ref:`text-anchors` for valid values.
563+
the anchor to the text. The default alignment is top left,
564+
specifically ``la`` for horizontal text and ``lt`` for
565+
vertical text. See :ref:`text-anchors` for details.
563566
564567
.. versionadded:: 8.0.0
565568

0 commit comments

Comments
 (0)