From 15f8ef02c9e363ed1d5dca96bbc302649b322b7f Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Fri, 22 Mar 2019 21:14:39 +1100 Subject: [PATCH] Updated freetype to 2.10.0 --- Tests/test_imagefont.py | 53 +++++++++++++++++++++++++---------------- winbuild/config.py | 6 ++--- 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/Tests/test_imagefont.py b/Tests/test_imagefont.py index ba5821c36..33f37916c 100644 --- a/Tests/test_imagefont.py +++ b/Tests/test_imagefont.py @@ -6,6 +6,8 @@ from io import BytesIO import os import sys import copy +import re +import distutils.version FONT_PATH = "Tests/fonts/FreeMono.ttf" FONT_SIZE = 20 @@ -49,29 +51,40 @@ class TestImageFont(PillowTestCase): # Freetype has different metrics depending on the version. # (and, other things, but first things first) METRICS = { - ('2', '3'): {'multiline': 30, - 'textsize': 12, - 'getters': (13, 16)}, - ('2', '7'): {'multiline': 6.2, - 'textsize': 2.5, - 'getters': (12, 16)}, - ('2', '8'): {'multiline': 6.2, - 'textsize': 2.5, - 'getters': (12, 16)}, - ('2', '9'): {'multiline': 6.2, - 'textsize': 2.5, - 'getters': (12, 16)}, - 'Default': {'multiline': 0.5, - 'textsize': 0.5, - 'getters': (12, 16)}, + ('>=2.3', '<2.4'): { + 'multiline': 30, + 'textsize': 12, + 'getters': (13, 16)}, + ('>=2.7',): { + 'multiline': 6.2, + 'textsize': 2.5, + 'getters': (12, 16)}, + 'Default': { + 'multiline': 0.5, + 'textsize': 0.5, + 'getters': (12, 16)}, } def setUp(self): - freetype_version = tuple( - ImageFont.core.freetype2_version.split('.') - )[:2] - self.metrics = self.METRICS.get(freetype_version, - self.METRICS['Default']) + freetype = distutils.version.StrictVersion(ImageFont.core.freetype2_version) + + self.metrics = self.METRICS['Default'] + for conditions, metrics in self.METRICS.items(): + if not isinstance(conditions, tuple): + continue + + for condition in conditions: + version = re.sub('[<=>]', '', condition) + if (condition.startswith('>=') and freetype >= version) or \ + (condition.startswith('<') and freetype < version): + # Condition was met + continue + + # Condition failed + break + else: + # All conditions were met + self.metrics = metrics def get_font(self): return ImageFont.truetype(FONT_PATH, FONT_SIZE, diff --git a/winbuild/config.py b/winbuild/config.py index da6f7855b..9001821a5 100644 --- a/winbuild/config.py +++ b/winbuild/config.py @@ -33,9 +33,9 @@ libs = { 'dir': 'tiff-4.0.10', }, 'freetype': { - 'url': 'https://download.savannah.gnu.org/releases/freetype/freetype-2.9.1.tar.gz', # noqa: E501 - 'filename': PILLOW_DEPENDS_DIR + 'freetype-2.9.1.tar.gz', - 'dir': 'freetype-2.9.1', + 'url': 'https://download.savannah.gnu.org/releases/freetype/freetype-2.10.0.tar.gz', # noqa: E501 + 'filename': PILLOW_DEPENDS_DIR + 'freetype-2.10.0.tar.gz', + 'dir': 'freetype-2.10.0', }, 'lcms': { 'url': SF_MIRROR+'/project/lcms/lcms/2.7/lcms2-2.7.zip',