Merge pull request #6220 from nulano/deprecate-fill

Deprecate FreeTypeFont.getmask2 fill parameter
This commit is contained in:
Andrew Murray 2022-04-18 08:05:10 +10:00 committed by GitHub
commit a33dc56560
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 80 additions and 1 deletions

View File

@ -977,6 +977,14 @@ class TestImageFont:
assert_image_similar_tofile(im, "Tests/images/colr_bungee_mask.png", 22) 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)
with pytest.warns(DeprecationWarning):
with pytest.raises(TypeError):
font.getmask2("Hello world", fill=None)
@skip_unless_feature("raqm") @skip_unless_feature("raqm")
class TestImageFont_RaqmLayout(TestImageFont): class TestImageFont_RaqmLayout(TestImageFont):

View File

@ -149,6 +149,14 @@ PhotoImage.paste box parameter
The ``box`` parameter is unused. It will be removed in Pillow 10.0.0 (2023-07-01). The ``box`` parameter is unused. It will be removed in Pillow 10.0.0 (2023-07-01).
FreeTypeFont.getmask2 fill parameter
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. deprecated:: 9.2.0
The undocumented ``fill`` parameter of :py:meth:`.FreeTypeFont.getmask2` has been
deprecated and will be removed in Pillow 10 (2023-07-01).
Removed features Removed features
---------------- ----------------

View File

@ -0,0 +1,49 @@
9.2.0
-----
Backwards Incompatible Changes
==============================
TODO
^^^^
Deprecations
============
FreeTypeFont.getmask2 fill parameter
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The undocumented ``fill`` parameter of :py:meth:`.FreeTypeFont.getmask2`
has been deprecated and will be removed in Pillow 10 (2023-07-01).
API Changes
===========
TODO
^^^^
TODO
API Additions
=============
TODO
^^^^
TODO
Security
========
TODO
^^^^
TODO
Other Changes
=============
TODO
^^^^
TODO

View File

@ -14,6 +14,7 @@ expected to be backported to earlier versions.
.. toctree:: .. toctree::
:maxdepth: 2 :maxdepth: 2
9.2.0
9.1.0 9.1.0
9.0.1 9.0.1
9.0.0 9.0.0

View File

@ -64,6 +64,9 @@ except ImportError:
core = _ImagingFtNotInstalled() core = _ImagingFtNotInstalled()
_UNSPECIFIED = object()
# FIXME: add support for pilfont2 format (see FontFile.py) # FIXME: add support for pilfont2 format (see FontFile.py)
# -------------------------------------------------------------------- # --------------------------------------------------------------------
@ -602,7 +605,7 @@ class FreeTypeFont:
self, self,
text, text,
mode="", mode="",
fill=Image.core.fill, fill=_UNSPECIFIED,
direction=None, direction=None,
features=None, features=None,
language=None, language=None,
@ -627,6 +630,12 @@ class FreeTypeFont:
.. versionadded:: 1.1.5 .. versionadded:: 1.1.5
:param fill: Optional fill function. By default, an internal Pillow function
will be used.
Deprecated. This parameter will be removed in Pillow 10
(2023-07-01).
:param direction: Direction of the text. It can be 'rtl' (right to :param direction: Direction of the text. It can be 'rtl' (right to
left), 'ltr' (left to right) or 'ttb' (top to bottom). left), 'ltr' (left to right) or 'ttb' (top to bottom).
Requires libraqm. Requires libraqm.
@ -674,6 +683,10 @@ class FreeTypeFont:
:py:mod:`PIL.Image.core` interface module, and the text offset, the :py:mod:`PIL.Image.core` interface module, and the text offset, the
gap between the starting coordinate and the first marking gap between the starting coordinate and the first marking
""" """
if fill is _UNSPECIFIED:
fill = Image.core.fill
else:
deprecate("fill", 10)
size, offset = self.font.getsize( size, offset = self.font.getsize(
text, mode, direction, features, language, anchor text, mode, direction, features, language, anchor
) )