mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-27 09:44:31 +03:00
Remove support for FreeType 2.7 and older
This commit is contained in:
parent
20cf82b2af
commit
606b5ae1e5
|
@ -757,11 +757,7 @@ class TestImageFont:
|
||||||
name, text = "quick", "Quick"
|
name, text = "quick", "Quick"
|
||||||
path = f"Tests/images/test_anchor_{name}_{anchor}.png"
|
path = f"Tests/images/test_anchor_{name}_{anchor}.png"
|
||||||
|
|
||||||
freetype = parse_version(features.version_module("freetype2"))
|
if self.LAYOUT_ENGINE == ImageFont.LAYOUT_RAQM:
|
||||||
if freetype < parse_version("2.4"):
|
|
||||||
width, height = (129, 44)
|
|
||||||
left = left_old
|
|
||||||
elif self.LAYOUT_ENGINE == ImageFont.LAYOUT_RAQM:
|
|
||||||
width, height = (129, 44)
|
width, height = (129, 44)
|
||||||
else:
|
else:
|
||||||
width, height = (128, 44)
|
width, height = (128, 44)
|
||||||
|
@ -894,7 +890,6 @@ class TestImageFont:
|
||||||
|
|
||||||
assert_image_similar_tofile(im, "Tests/images/standard_embedded.png", 6.2)
|
assert_image_similar_tofile(im, "Tests/images/standard_embedded.png", 6.2)
|
||||||
|
|
||||||
@skip_unless_feature_version("freetype2", "2.5.0")
|
|
||||||
def test_cbdt(self):
|
def test_cbdt(self):
|
||||||
try:
|
try:
|
||||||
font = ImageFont.truetype(
|
font = ImageFont.truetype(
|
||||||
|
@ -913,7 +908,6 @@ class TestImageFont:
|
||||||
assert str(e) in ("unimplemented feature", "unknown file format")
|
assert str(e) in ("unimplemented feature", "unknown file format")
|
||||||
pytest.skip("freetype compiled without libpng or CBDT support")
|
pytest.skip("freetype compiled without libpng or CBDT support")
|
||||||
|
|
||||||
@skip_unless_feature_version("freetype2", "2.5.0")
|
|
||||||
def test_cbdt_mask(self):
|
def test_cbdt_mask(self):
|
||||||
try:
|
try:
|
||||||
font = ImageFont.truetype(
|
font = ImageFont.truetype(
|
||||||
|
@ -934,7 +928,6 @@ class TestImageFont:
|
||||||
assert str(e) in ("unimplemented feature", "unknown file format")
|
assert str(e) in ("unimplemented feature", "unknown file format")
|
||||||
pytest.skip("freetype compiled without libpng or CBDT support")
|
pytest.skip("freetype compiled without libpng or CBDT support")
|
||||||
|
|
||||||
@skip_unless_feature_version("freetype2", "2.5.1")
|
|
||||||
def test_sbix(self):
|
def test_sbix(self):
|
||||||
try:
|
try:
|
||||||
font = ImageFont.truetype(
|
font = ImageFont.truetype(
|
||||||
|
@ -953,7 +946,6 @@ class TestImageFont:
|
||||||
assert str(e) in ("unimplemented feature", "unknown file format")
|
assert str(e) in ("unimplemented feature", "unknown file format")
|
||||||
pytest.skip("freetype compiled without libpng or SBIX support")
|
pytest.skip("freetype compiled without libpng or SBIX support")
|
||||||
|
|
||||||
@skip_unless_feature_version("freetype2", "2.5.1")
|
|
||||||
def test_sbix_mask(self):
|
def test_sbix_mask(self):
|
||||||
try:
|
try:
|
||||||
font = ImageFont.truetype(
|
font = ImageFont.truetype(
|
||||||
|
@ -1008,7 +1000,6 @@ class TestImageFont_RaqmLayout(TestImageFont):
|
||||||
LAYOUT_ENGINE = ImageFont.LAYOUT_RAQM
|
LAYOUT_ENGINE = ImageFont.LAYOUT_RAQM
|
||||||
|
|
||||||
|
|
||||||
@skip_unless_feature_version("freetype2", "2.4", "Different metrics")
|
|
||||||
def test_render_mono_size():
|
def test_render_mono_size():
|
||||||
# issue 4177
|
# issue 4177
|
||||||
|
|
||||||
|
@ -1024,18 +1015,6 @@ def test_render_mono_size():
|
||||||
assert_image_equal_tofile(im, "Tests/images/text_mono.gif")
|
assert_image_equal_tofile(im, "Tests/images/text_mono.gif")
|
||||||
|
|
||||||
|
|
||||||
def test_freetype_deprecation(monkeypatch):
|
|
||||||
# Arrange: mock features.version_module to return fake FreeType version
|
|
||||||
def fake_version_module(module):
|
|
||||||
return "2.7"
|
|
||||||
|
|
||||||
monkeypatch.setattr(features, "version_module", fake_version_module)
|
|
||||||
|
|
||||||
# Act / Assert
|
|
||||||
with pytest.warns(DeprecationWarning):
|
|
||||||
ImageFont.truetype(FONT_PATH, FONT_SIZE)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"test_file",
|
"test_file",
|
||||||
[
|
[
|
||||||
|
|
|
@ -1,13 +1,8 @@
|
||||||
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
|
||||||
|
|
||||||
from .helper import (
|
from .helper import assert_image_similar_tofile, skip_unless_feature
|
||||||
assert_image_similar_tofile,
|
|
||||||
skip_unless_feature,
|
|
||||||
skip_unless_feature_version,
|
|
||||||
)
|
|
||||||
|
|
||||||
FONT_SIZE = 20
|
FONT_SIZE = 20
|
||||||
FONT_PATH = "Tests/fonts/DejaVuSans/DejaVuSans.ttf"
|
FONT_PATH = "Tests/fonts/DejaVuSans/DejaVuSans.ttf"
|
||||||
|
@ -252,11 +247,6 @@ def test_getlength_combine(mode, direction, text):
|
||||||
pytest.skip("libraqm 0.7 or greater not available")
|
pytest.skip("libraqm 0.7 or greater not available")
|
||||||
|
|
||||||
|
|
||||||
# FreeType 2.5.1 README: Miscellaneous Changes:
|
|
||||||
# Improved computation of emulated vertical metrics for TrueType fonts.
|
|
||||||
@skip_unless_feature_version(
|
|
||||||
"freetype2", "2.5.1", "FreeType <2.5.1 has incompatible ttb metrics"
|
|
||||||
)
|
|
||||||
@pytest.mark.parametrize("anchor", ("lt", "mm", "rb", "sm"))
|
@pytest.mark.parametrize("anchor", ("lt", "mm", "rb", "sm"))
|
||||||
def test_anchor_ttb(anchor):
|
def test_anchor_ttb(anchor):
|
||||||
text = "f"
|
text = "f"
|
||||||
|
@ -315,14 +305,6 @@ combine_tests = (
|
||||||
"name, text, anchor, dir, epsilon", combine_tests, ids=[r[0] for r in combine_tests]
|
"name, text, anchor, dir, epsilon", combine_tests, ids=[r[0] for r in combine_tests]
|
||||||
)
|
)
|
||||||
def test_combine(name, text, dir, anchor, epsilon):
|
def test_combine(name, text, dir, anchor, epsilon):
|
||||||
if (
|
|
||||||
parse_version(features.version_module("freetype2")) < parse_version("2.5.1")
|
|
||||||
and dir == "ttb"
|
|
||||||
):
|
|
||||||
# FreeType 2.5.1 README: Miscellaneous Changes:
|
|
||||||
# Improved computation of emulated vertical metrics for TrueType fonts.
|
|
||||||
pytest.skip("FreeType <2.5.1 has incompatible ttb metrics")
|
|
||||||
|
|
||||||
path = f"Tests/images/test_combine_{name}.png"
|
path = f"Tests/images/test_combine_{name}.png"
|
||||||
f = ImageFont.truetype("Tests/fonts/NotoSans-Regular.ttf", 48)
|
f = ImageFont.truetype("Tests/fonts/NotoSans-Regular.ttf", 48)
|
||||||
|
|
||||||
|
|
|
@ -12,19 +12,6 @@ Deprecated features
|
||||||
Below are features which are considered deprecated. Where appropriate,
|
Below are features which are considered deprecated. Where appropriate,
|
||||||
a ``DeprecationWarning`` is issued.
|
a ``DeprecationWarning`` is issued.
|
||||||
|
|
||||||
FreeType 2.7
|
|
||||||
~~~~~~~~~~~~
|
|
||||||
|
|
||||||
.. deprecated:: 8.1.0
|
|
||||||
|
|
||||||
Support for FreeType 2.7 is deprecated and will be removed in Pillow 9.0.0 (2022-01-02),
|
|
||||||
when FreeType 2.8 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:`CVE-2020-15999`).
|
|
||||||
|
|
||||||
.. _2.10.4: https://sourceforge.net/projects/freetype/files/freetype2/2.10.4/
|
|
||||||
|
|
||||||
Tk/Tcl 8.4
|
Tk/Tcl 8.4
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
|
|
||||||
|
@ -111,6 +98,19 @@ ImageFile.raise_ioerror
|
||||||
So, ``ImageFile.raise_ioerror`` has been removed.
|
So, ``ImageFile.raise_ioerror`` has been removed.
|
||||||
Use ``ImageFile.raise_oserror`` instead.
|
Use ``ImageFile.raise_oserror`` instead.
|
||||||
|
|
||||||
|
FreeType 2.7
|
||||||
|
~~~~~~~~~~~~
|
||||||
|
|
||||||
|
.. deprecated:: 8.1.0
|
||||||
|
.. versionremoved:: 9.0.0
|
||||||
|
|
||||||
|
Support for FreeType 2.7 has been removed.
|
||||||
|
|
||||||
|
We recommend upgrading to at least `FreeType`_ 2.10.4, which fixed a severe
|
||||||
|
vulnerability introduced in FreeType 2.6 (:cve:`CVE-2020-15999`).
|
||||||
|
|
||||||
|
.. _FreeType: https://www.freetype.org
|
||||||
|
|
||||||
im.offset
|
im.offset
|
||||||
~~~~~~~~~
|
~~~~~~~~~
|
||||||
|
|
||||||
|
|
|
@ -9,25 +9,44 @@ PILLOW_VERSION constant
|
||||||
|
|
||||||
``PILLOW_VERSION`` has been removed. Use ``__version__`` instead.
|
``PILLOW_VERSION`` has been removed. Use ``__version__`` instead.
|
||||||
|
|
||||||
|
FreeType 2.7
|
||||||
|
^^^^^^^^^^^^
|
||||||
|
|
||||||
|
Support for FreeType 2.7 has been removed; FreeType 2.8 is the minimum supported.
|
||||||
|
|
||||||
|
We recommend upgrading to at least `FreeType`_ 2.10.4, which fixed a severe
|
||||||
|
vulnerability introduced in FreeType 2.6 (:cve:`CVE-2020-15999`).
|
||||||
|
|
||||||
|
.. _FreeType: https://www.freetype.org
|
||||||
|
|
||||||
Image.show command parameter
|
Image.show command parameter
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
The ``command`` parameter has been removed. Use a subclass of
|
The ``command`` parameter has been removed. Use a subclass of
|
||||||
:py:class:`PIL.ImageShow.Viewer` instead.
|
:py:class:`PIL.ImageShow.Viewer` instead.
|
||||||
|
|
||||||
Image._showxv
|
Image._showxv
|
||||||
~~~~~~~~~~~~~
|
^^^^^^^^^^^^^
|
||||||
|
|
||||||
``Image._showxv`` has been removed. Use :py:meth:`~PIL.Image.Image.show`
|
``Image._showxv`` has been removed. Use :py:meth:`~PIL.Image.Image.show`
|
||||||
instead. If custom behaviour is required, use :py:meth:`~PIL.ImageShow.register` to add
|
instead. If custom behaviour is required, use :py:meth:`~PIL.ImageShow.register` to add
|
||||||
a custom :py:class:`~PIL.ImageShow.Viewer` class.
|
a custom :py:class:`~PIL.ImageShow.Viewer` class.
|
||||||
|
|
||||||
ImageFile.raise_ioerror
|
ImageFile.raise_ioerror
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~
|
^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
``IOError`` was merged into ``OSError`` in Python 3.3. So, ``ImageFile.raise_ioerror``
|
``IOError`` was merged into ``OSError`` in Python 3.3. So, ``ImageFile.raise_ioerror``
|
||||||
has been removed. Use ``ImageFile.raise_oserror`` instead.
|
has been removed. Use ``ImageFile.raise_oserror`` instead.
|
||||||
|
|
||||||
|
|
||||||
|
Deprecations
|
||||||
|
============
|
||||||
|
|
||||||
|
TODO
|
||||||
|
^^^^
|
||||||
|
|
||||||
|
TODO
|
||||||
|
|
||||||
API Changes
|
API Changes
|
||||||
===========
|
===========
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,9 @@ TODO
|
||||||
Security
|
Security
|
||||||
========
|
========
|
||||||
|
|
||||||
|
TODO
|
||||||
|
^^^^
|
||||||
|
|
||||||
TODO
|
TODO
|
||||||
|
|
||||||
Other Changes
|
Other Changes
|
||||||
|
|
|
@ -28,10 +28,9 @@
|
||||||
import base64
|
import base64
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import warnings
|
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
from . import Image, features
|
from . import Image
|
||||||
from ._util import isDirectory, isPath
|
from ._util import isDirectory, isPath
|
||||||
|
|
||||||
LAYOUT_BASIC = 0
|
LAYOUT_BASIC = 0
|
||||||
|
@ -165,23 +164,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:
|
|
||||||
freetype_version = features.version_module("freetype2")
|
|
||||||
if freetype_version is not None and parse_version(
|
|
||||||
freetype_version
|
|
||||||
) < parse_version("2.8"):
|
|
||||||
warnings.warn(
|
|
||||||
"Support for FreeType 2.7 is deprecated and will be removed"
|
|
||||||
" in Pillow 9 (2022-01-02). Please upgrade to FreeType 2.8 "
|
|
||||||
"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:
|
||||||
|
|
|
@ -933,11 +933,7 @@ font_render(FontObject *self, PyObject *args) {
|
||||||
case FT_PIXEL_MODE_GRAY2:
|
case FT_PIXEL_MODE_GRAY2:
|
||||||
case FT_PIXEL_MODE_GRAY4:
|
case FT_PIXEL_MODE_GRAY4:
|
||||||
if (!bitmap_converted_ready) {
|
if (!bitmap_converted_ready) {
|
||||||
#if FREETYPE_MAJOR > 2 || (FREETYPE_MAJOR == 2 && FREETYPE_MINOR > 6)
|
|
||||||
FT_Bitmap_Init(&bitmap_converted);
|
FT_Bitmap_Init(&bitmap_converted);
|
||||||
#else
|
|
||||||
FT_Bitmap_New(&bitmap_converted);
|
|
||||||
#endif
|
|
||||||
bitmap_converted_ready = 1;
|
bitmap_converted_ready = 1;
|
||||||
}
|
}
|
||||||
error = FT_Bitmap_Convert(library, &bitmap, &bitmap_converted, 1);
|
error = FT_Bitmap_Convert(library, &bitmap, &bitmap_converted, 1);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user