From 067a2543668ef95951b330db5458a84666b66be1 Mon Sep 17 00:00:00 2001 From: nulano Date: Sun, 11 Oct 2020 21:55:32 +0200 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Hugo van Kemenade --- docs/reference/ImageDraw.rst | 8 +++----- src/PIL/ImageFont.py | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/docs/reference/ImageDraw.rst b/docs/reference/ImageDraw.rst index bed20266a..2af8f49c8 100644 --- a/docs/reference/ImageDraw.rst +++ b/docs/reference/ImageDraw.rst @@ -411,8 +411,6 @@ Methods the ascender line instead of the top, see :ref:`text-anchors`. If you wish to measure text height from the top, it is recommended to use :meth:`textbbox` with ``anchor='lt'`` instead. - - :param text: Text to be measured. If it contains any newline characters, the text is passed on to :py:meth:`~PIL.ImageDraw.ImageDraw.multiline_textsize`. :param font: An :py:class:`~PIL.ImageFont.ImageFont` instance. @@ -498,7 +496,7 @@ Methods .. py:method:: ImageDraw.textlength(text, font=None, direction=None, features=None, language=None) - Returns length (in pixels with 1/64 precision) of given text if rendered + Returns length (in pixels with 1/64 precision) of given text when rendered in font with provided direction, features, and language. This is the amount by which following text should be offset. @@ -567,7 +565,7 @@ Methods .. py:method:: ImageDraw.textbbox(xy, text, font=None, anchor=None, spacing=4, align="left", direction=None, features=None, language=None, stroke_width=0) Returns bounding box (in pixels) of given text relative to given anchor - if rendered in font with provided direction, features, and language. + when rendered in font with provided direction, features, and language. Only supported for TrueType fonts. Use :py:meth:`textlength` to get the offset of following text with @@ -615,7 +613,7 @@ Methods .. py:method:: ImageDraw.multiline_textbbox(xy, text, font=None, anchor=None, spacing=4, align="left", direction=None, features=None, language=None, stroke_width=0) Returns bounding box (in pixels) of given text relative to given anchor - if rendered in font with provided direction, features, and language. + when rendered in font with provided direction, features, and language. Only supported for TrueType fonts. Use :py:meth:`textlength` to get the offset of following text with diff --git a/src/PIL/ImageFont.py b/src/PIL/ImageFont.py index 18a14d4fe..4ca9cc656 100644 --- a/src/PIL/ImageFont.py +++ b/src/PIL/ImageFont.py @@ -217,7 +217,7 @@ class FreeTypeFont: def getlength(self, text, mode="", direction=None, features=None, language=None): """ - Returns length (in pixels with 1/64 precision) of given text if rendered + Returns length (in pixels with 1/64 precision) of given text when rendered in font with provided direction, features, and language. This is the amount by which following text should be offset. @@ -306,7 +306,7 @@ class FreeTypeFont: ): """ Returns bounding box (in pixels) of given text relative to given anchor - if rendered in font with provided direction, features, and language. + when rendered in font with provided direction, features, and language. Use :py:meth:`getlength()` to get the offset of following text with 1/64 pixel precision. The bounding box includes extra margins for