mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-03-23 19:44:13 +03:00
Merge pull request #3734 from radarhere/freetype
Updated freetype to 2.10.0
This commit is contained in:
commit
42a6e2de02
|
@ -6,6 +6,8 @@ from io import BytesIO
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import copy
|
import copy
|
||||||
|
import re
|
||||||
|
import distutils.version
|
||||||
|
|
||||||
FONT_PATH = "Tests/fonts/FreeMono.ttf"
|
FONT_PATH = "Tests/fonts/FreeMono.ttf"
|
||||||
FONT_SIZE = 20
|
FONT_SIZE = 20
|
||||||
|
@ -49,29 +51,40 @@ class TestImageFont(PillowTestCase):
|
||||||
# Freetype has different metrics depending on the version.
|
# Freetype has different metrics depending on the version.
|
||||||
# (and, other things, but first things first)
|
# (and, other things, but first things first)
|
||||||
METRICS = {
|
METRICS = {
|
||||||
('2', '3'): {'multiline': 30,
|
('>=2.3', '<2.4'): {
|
||||||
'textsize': 12,
|
'multiline': 30,
|
||||||
'getters': (13, 16)},
|
'textsize': 12,
|
||||||
('2', '7'): {'multiline': 6.2,
|
'getters': (13, 16)},
|
||||||
'textsize': 2.5,
|
('>=2.7',): {
|
||||||
'getters': (12, 16)},
|
'multiline': 6.2,
|
||||||
('2', '8'): {'multiline': 6.2,
|
'textsize': 2.5,
|
||||||
'textsize': 2.5,
|
'getters': (12, 16)},
|
||||||
'getters': (12, 16)},
|
'Default': {
|
||||||
('2', '9'): {'multiline': 6.2,
|
'multiline': 0.5,
|
||||||
'textsize': 2.5,
|
'textsize': 0.5,
|
||||||
'getters': (12, 16)},
|
'getters': (12, 16)},
|
||||||
'Default': {'multiline': 0.5,
|
|
||||||
'textsize': 0.5,
|
|
||||||
'getters': (12, 16)},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
freetype_version = tuple(
|
freetype = distutils.version.StrictVersion(ImageFont.core.freetype2_version)
|
||||||
ImageFont.core.freetype2_version.split('.')
|
|
||||||
)[:2]
|
self.metrics = self.METRICS['Default']
|
||||||
self.metrics = self.METRICS.get(freetype_version,
|
for conditions, metrics in self.METRICS.items():
|
||||||
self.METRICS['Default'])
|
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):
|
def get_font(self):
|
||||||
return ImageFont.truetype(FONT_PATH, FONT_SIZE,
|
return ImageFont.truetype(FONT_PATH, FONT_SIZE,
|
||||||
|
|
|
@ -33,9 +33,9 @@ libs = {
|
||||||
'dir': 'tiff-4.0.10',
|
'dir': 'tiff-4.0.10',
|
||||||
},
|
},
|
||||||
'freetype': {
|
'freetype': {
|
||||||
'url': 'https://download.savannah.gnu.org/releases/freetype/freetype-2.9.1.tar.gz', # noqa: E501
|
'url': 'https://download.savannah.gnu.org/releases/freetype/freetype-2.10.0.tar.gz', # noqa: E501
|
||||||
'filename': PILLOW_DEPENDS_DIR + 'freetype-2.9.1.tar.gz',
|
'filename': PILLOW_DEPENDS_DIR + 'freetype-2.10.0.tar.gz',
|
||||||
'dir': 'freetype-2.9.1',
|
'dir': 'freetype-2.10.0',
|
||||||
},
|
},
|
||||||
'lcms': {
|
'lcms': {
|
||||||
'url': SF_MIRROR+'/project/lcms/lcms/2.7/lcms2-2.7.zip',
|
'url': SF_MIRROR+'/project/lcms/lcms/2.7/lcms2-2.7.zip',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user