From ad5271d62f65deb67b10c1938fff782e68ab3e62 Mon Sep 17 00:00:00 2001 From: nulano <nulano@nulano.eu> Date: Thu, 30 Jun 2022 15:02:09 +0200 Subject: [PATCH] Document replacements for individual deprecated font methods --- docs/reference/ImageDraw.rst | 8 ++++---- src/PIL/ImageFont.py | 11 +++++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/docs/reference/ImageDraw.rst b/docs/reference/ImageDraw.rst index 1ba024eea9d..e6e2d15c06b 100644 --- a/docs/reference/ImageDraw.rst +++ b/docs/reference/ImageDraw.rst @@ -437,13 +437,12 @@ Methods .. py:method:: ImageDraw.textsize(text, font=None, spacing=4, direction=None, features=None, language=None, stroke_width=0) .. deprecated:: 9.2.0 + Use :py:meth:`textlength()` to measure the offset of following text with + 1/64 pixel precision. + Use :py:meth:`textbbox()` to get the exact bounding box based on an anchor. Return the size of the given string, in pixels. - Use :py:meth:`textlength()` to measure the offset of following text with - 1/64 pixel precision. - Use :py:meth:`textbbox()` to get the exact bounding box based on an anchor. - .. note:: For historical reasons this function measures text height from the ascender line instead of the top, see :ref:`text-anchors`. If you wish to measure text height from the top, it is recommended @@ -487,6 +486,7 @@ Methods .. py:method:: ImageDraw.multiline_textsize(text, font=None, spacing=4, direction=None, features=None, language=None, stroke_width=0) .. deprecated:: 9.2.0 + Use :py:meth:`.multiline_textbbox` instead. Return the size of the given string, in pixels. diff --git a/src/PIL/ImageFont.py b/src/PIL/ImageFont.py index 1f356adefd9..8c23b59b6be 100644 --- a/src/PIL/ImageFont.py +++ b/src/PIL/ImageFont.py @@ -138,6 +138,7 @@ def _load_pilfont_data(self, file, image): def getsize(self, text, *args, **kwargs): """ .. deprecated:: 9.2.0 + Use :py:meth:`.getbbox` or :py:meth:`.getlength` instead. Returns width and height (in pixels) of given text. @@ -427,14 +428,13 @@ def getsize( ): """ .. deprecated:: 9.2.0 + Use :py:meth:`getlength()` to measure the offset of following text with + 1/64 pixel precision. + Use :py:meth:`getbbox()` to get the exact bounding box based on an anchor. Returns width and height (in pixels) of given text if rendered in font with provided direction, features, and language. - Use :py:meth:`getlength()` to measure the offset of following text with - 1/64 pixel precision. - Use :py:meth:`getbbox()` to get the exact bounding box based on an anchor. - .. note:: For historical reasons this function measures text height from the ascender line instead of the top, see :ref:`text-anchors`. If you wish to measure text height from the top, it is recommended @@ -498,6 +498,7 @@ def getsize_multiline( ): """ .. deprecated:: 9.2.0 + Use :py:meth:`.ImageDraw.multiline_textbbox` instead. Returns width and height (in pixels) of given text if rendered in font with provided direction, features, and language, while respecting @@ -555,6 +556,7 @@ def getsize_multiline( def getoffset(self, text): """ .. deprecated:: 9.2.0 + Use :py:meth:`.getbbox` instead. Returns the offset of given text. This is the gap between the starting coordinate and the first marking. Note that this gap is @@ -847,6 +849,7 @@ def __init__(self, font, orientation=None): def getsize(self, text, *args, **kwargs): """ .. deprecated:: 9.2.0 + Use :py:meth:`.getbbox` or :py:meth:`.getlength` instead. """ if not kwargs.get("__internal__"): deprecate("getsize", 10, "getbbox or getlength")