Merge pull request #3734 from radarhere/freetype

Updated freetype to 2.10.0
This commit is contained in:
Hugo 2019-03-22 13:17:06 +02:00 committed by GitHub
commit 42a6e2de02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 23 deletions

View File

@ -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,

View File

@ -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',