Removed support for FreeType <= 2.9.0

This commit is contained in:
Andrew Murray 2025-07-01 21:44:33 +10:00
parent aaf217cea0
commit 92bafe6b88
3 changed files with 18 additions and 71 deletions

View File

@ -11,7 +11,6 @@ from pathlib import Path
from typing import Any, BinaryIO from typing import Any, BinaryIO
import pytest import pytest
from packaging.version import parse as parse_version
from PIL import Image, ImageDraw, ImageFont, features from PIL import Image, ImageDraw, ImageFont, features
from PIL._typing import StrOrBytesPath from PIL._typing import StrOrBytesPath
@ -691,16 +690,6 @@ def test_complex_font_settings() -> None:
def test_variation_get(font: ImageFont.FreeTypeFont) -> None: def test_variation_get(font: ImageFont.FreeTypeFont) -> None:
version = features.version_module("freetype2")
assert version is not None
freetype = parse_version(version)
if freetype < parse_version("2.9.1"):
with pytest.raises(NotImplementedError):
font.get_variation_names()
with pytest.raises(NotImplementedError):
font.get_variation_axes()
return
with pytest.raises(OSError): with pytest.raises(OSError):
font.get_variation_names() font.get_variation_names()
with pytest.raises(OSError): with pytest.raises(OSError):
@ -763,14 +752,6 @@ def _check_text(font: ImageFont.FreeTypeFont, path: str, epsilon: float) -> None
def test_variation_set_by_name(font: ImageFont.FreeTypeFont) -> None: def test_variation_set_by_name(font: ImageFont.FreeTypeFont) -> None:
version = features.version_module("freetype2")
assert version is not None
freetype = parse_version(version)
if freetype < parse_version("2.9.1"):
with pytest.raises(NotImplementedError):
font.set_variation_by_name("Bold")
return
with pytest.raises(OSError): with pytest.raises(OSError):
font.set_variation_by_name("Bold") font.set_variation_by_name("Bold")
@ -790,14 +771,6 @@ def test_variation_set_by_name(font: ImageFont.FreeTypeFont) -> None:
def test_variation_set_by_axes(font: ImageFont.FreeTypeFont) -> None: def test_variation_set_by_axes(font: ImageFont.FreeTypeFont) -> None:
version = features.version_module("freetype2")
assert version is not None
freetype = parse_version(version)
if freetype < parse_version("2.9.1"):
with pytest.raises(NotImplementedError):
font.set_variation_by_axes([100])
return
with pytest.raises(OSError): with pytest.raises(OSError):
font.set_variation_by_axes([500, 50]) font.set_variation_by_axes([500, 50])
@ -1209,15 +1182,3 @@ def test_invalid_truetype_sizes_raise_valueerror(
) -> None: ) -> None:
with pytest.raises(ValueError): with pytest.raises(ValueError):
ImageFont.truetype(FONT_PATH, size, layout_engine=layout_engine) ImageFont.truetype(FONT_PATH, size, layout_engine=layout_engine)
def test_freetype_deprecation(monkeypatch: pytest.MonkeyPatch) -> None:
# Arrange: mock features.version_module to return fake FreeType version
def fake_version_module(module: str) -> str:
return "2.9.0"
monkeypatch.setattr(features, "version_module", fake_version_module)
# Act / Assert
with pytest.warns(DeprecationWarning, match="FreeType 2.9.0"):
ImageFont.truetype(FONT_PATH, FONT_SIZE)

View File

@ -19,19 +19,6 @@ ImageDraw.getdraw hints parameter
The ``hints`` parameter in :py:meth:`~PIL.ImageDraw.getdraw()` has been deprecated. The ``hints`` parameter in :py:meth:`~PIL.ImageDraw.getdraw()` has been deprecated.
FreeType 2.9.0
^^^^^^^^^^^^^^
.. deprecated:: 11.0.0
Support for FreeType 2.9.0 is deprecated and will be removed in Pillow 12.0.0
(2025-10-15), when FreeType 2.9.1 will be the minimum supported.
We recommend upgrading to at least FreeType `2.10.4`_, which fixed a severe
vulnerability introduced in FreeType 2.6 (:cve:`2020-15999`).
.. _2.10.4: https://sourceforge.net/projects/freetype/files/freetype2/2.10.4/
ExifTags.IFD.Makernote ExifTags.IFD.Makernote
^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^
@ -79,7 +66,7 @@ Deprecated features are only removed in major releases after an appropriate
period of deprecation has passed. period of deprecation has passed.
ImageFile.raise_oserror ImageFile.raise_oserror
~~~~~~~~~~~~~~~~~~~~~~~ ^^^^^^^^^^^^^^^^^^^^^^^
.. deprecated:: 10.2.0 .. deprecated:: 10.2.0
.. versionremoved:: 12.0.0 .. versionremoved:: 12.0.0
@ -89,7 +76,7 @@ only useful for translating error codes returned by a codec's ``decode()`` metho
which ImageFile already did automatically. which ImageFile already did automatically.
IptcImageFile helper functions IptcImageFile helper functions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. deprecated:: 10.2.0 .. deprecated:: 10.2.0
.. versionremoved:: 12.0.0 .. versionremoved:: 12.0.0
@ -100,7 +87,7 @@ intended for internal use, so there is no replacement. They can each be replaced
single line of code using builtin functions in Python. single line of code using builtin functions in Python.
ImageCms constants and versions() function ImageCms constants and versions() function
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. deprecated:: 10.3.0 .. deprecated:: 10.3.0
.. versionremoved:: 12.0.0 .. versionremoved:: 12.0.0
@ -181,6 +168,20 @@ ImageDraw.getdraw hints parameter
The ``hints`` parameter in :py:meth:`~PIL.ImageDraw.getdraw()` has been removed. The ``hints`` parameter in :py:meth:`~PIL.ImageDraw.getdraw()` has been removed.
FreeType 2.9.0
^^^^^^^^^^^^^^
.. deprecated:: 11.0.0
.. versionremoved:: 12.0.0
Support for FreeType 2.9.0 has been removed. FreeType 2.9.1 is the minimum version
supported.
We recommend upgrading to at least FreeType `2.10.4`_, which fixed a severe
vulnerability introduced in FreeType 2.6 (:cve:`2020-15999`).
.. _2.10.4: https://sourceforge.net/projects/freetype/files/freetype2/2.10.4/
ICNS (width, height, scale) sizes ICNS (width, height, scale) sizes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -36,7 +36,7 @@ from io import BytesIO
from types import ModuleType from types import ModuleType
from typing import IO, Any, BinaryIO, TypedDict, cast from typing import IO, Any, BinaryIO, TypedDict, cast
from . import Image, features from . import Image
from ._typing import StrOrBytesPath from ._typing import StrOrBytesPath
from ._util import DeferredError, is_path from ._util import DeferredError, is_path
@ -236,21 +236,6 @@ class FreeTypeFont:
self.index = index self.index = index
self.encoding = encoding self.encoding = encoding
try:
from packaging.version import parse as parse_version
except ImportError:
pass
else:
if freetype_version := features.version_module("freetype2"):
if parse_version(freetype_version) < parse_version("2.9.1"):
warnings.warn(
"Support for FreeType 2.9.0 is deprecated and will be removed "
"in Pillow 12 (2025-10-15). Please upgrade to FreeType 2.9.1 "
"or newer, preferably FreeType 2.10.4 which fixes "
"CVE-2020-15999.",
DeprecationWarning,
)
if layout_engine not in (Layout.BASIC, Layout.RAQM): if layout_engine not in (Layout.BASIC, Layout.RAQM):
layout_engine = Layout.BASIC layout_engine = Layout.BASIC
if core.HAVE_RAQM: if core.HAVE_RAQM: