From a766b5b0d5ab541dd93876f124da2b080fa79ff0 Mon Sep 17 00:00:00 2001 From: nulano Date: Sat, 16 Apr 2022 17:07:32 +0200 Subject: [PATCH] deprecate fill in imageFont --- Tests/test_imagefont.py | 5 +++++ src/PIL/ImageFont.py | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Tests/test_imagefont.py b/Tests/test_imagefont.py index f9d0a4c4f..a8fdddc24 100644 --- a/Tests/test_imagefont.py +++ b/Tests/test_imagefont.py @@ -977,6 +977,11 @@ class TestImageFont: assert_image_similar_tofile(im, "Tests/images/colr_bungee_mask.png", 22) + def test_fill_deprecation(self): + font = self.get_font() + with pytest.warns(DeprecationWarning): + font.getmask2("Hello world", fill=Image.core.fill) + @skip_unless_feature("raqm") class TestImageFont_RaqmLayout(TestImageFont): diff --git a/src/PIL/ImageFont.py b/src/PIL/ImageFont.py index f420e197e..77dce3bc6 100644 --- a/src/PIL/ImageFont.py +++ b/src/PIL/ImageFont.py @@ -602,7 +602,7 @@ class FreeTypeFont: self, text, mode="", - fill=Image.core.fill, + fill=None, direction=None, features=None, language=None, @@ -627,6 +627,8 @@ class FreeTypeFont: .. versionadded:: 1.1.5 + :param fill: Fill function. Deprecated. + :param direction: Direction of the text. It can be 'rtl' (right to left), 'ltr' (left to right) or 'ttb' (top to bottom). Requires libraqm. @@ -674,6 +676,10 @@ class FreeTypeFont: :py:mod:`PIL.Image.core` interface module, and the text offset, the gap between the starting coordinate and the first marking """ + if fill is not None: + deprecate("fill", 10) + else: + fill = Image.core.fill size, offset = self.font.getsize( text, mode, direction, features, language, anchor )