mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-05-31 11:13:08 +03:00
Merge pull request #2641 from hugovk/fix-unexpected-align
Fix unexpected keyword argument 'align'
This commit is contained in:
commit
3967e00bcd
|
@ -36,6 +36,7 @@ class _imagingft_not_installed(object):
|
||||||
def __getattr__(self, id):
|
def __getattr__(self, id):
|
||||||
raise ImportError("The _imagingft C module is not installed")
|
raise ImportError("The _imagingft C module is not installed")
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from . import _imagingft as core
|
from . import _imagingft as core
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -113,7 +114,6 @@ class ImageFont(object):
|
||||||
return self.font.getmask(text, mode)
|
return self.font.getmask(text, mode)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Wrapper for FreeType fonts. Application code should use the
|
# Wrapper for FreeType fonts. Application code should use the
|
||||||
# <b>truetype</b> factory function to create font objects.
|
# <b>truetype</b> factory function to create font objects.
|
||||||
|
@ -162,7 +162,7 @@ class FreeTypeFont(object):
|
||||||
def getmask(self, text, mode="", direction=None, features=None):
|
def getmask(self, text, mode="", direction=None, features=None):
|
||||||
return self.getmask2(text, mode, direction=direction, features=features)[0]
|
return self.getmask2(text, mode, direction=direction, features=features)[0]
|
||||||
|
|
||||||
def getmask2(self, text, mode="", fill=Image.core.fill, direction=None, features=None):
|
def getmask2(self, text, mode="", fill=Image.core.fill, direction=None, features=None, *args, **kwargs):
|
||||||
size, offset = self.font.getsize(text, direction, features)
|
size, offset = self.font.getsize(text, direction, features)
|
||||||
im = fill("L", size, 0)
|
im = fill("L", size, 0)
|
||||||
self.font.render(text, im.id, mode == "1", direction, features)
|
self.font.render(text, im.id, mode == "1", direction, features)
|
||||||
|
|
|
@ -40,13 +40,15 @@ class SimplePatcher(object):
|
||||||
else:
|
else:
|
||||||
delattr(self._parent_obj, self._attr_name)
|
delattr(self._parent_obj, self._attr_name)
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipUnless(HAS_FREETYPE, "ImageFont not Available")
|
@unittest.skipUnless(HAS_FREETYPE, "ImageFont not Available")
|
||||||
class TestImageFont(PillowTestCase):
|
class TestImageFont(PillowTestCase):
|
||||||
LAYOUT_ENGINE = ImageFont.LAYOUT_BASIC
|
LAYOUT_ENGINE = ImageFont.LAYOUT_BASIC
|
||||||
|
|
||||||
# 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 = { ('2', '3'): {'multiline': 30,
|
METRICS = {
|
||||||
|
('2', '3'): {'multiline': 30,
|
||||||
'textsize': 12,
|
'textsize': 12,
|
||||||
'getters': (13, 16)},
|
'getters': (13, 16)},
|
||||||
('2', '7'): {'multiline': 6.2,
|
('2', '7'): {'multiline': 6.2,
|
||||||
|
@ -213,6 +215,14 @@ class TestImageFont(PillowTestCase):
|
||||||
font=ttf,
|
font=ttf,
|
||||||
align="unknown"))
|
align="unknown"))
|
||||||
|
|
||||||
|
def test_draw_align(self):
|
||||||
|
im = Image.new('RGB', (300, 100), 'white')
|
||||||
|
draw = ImageDraw.Draw(im)
|
||||||
|
ttf = self.get_font()
|
||||||
|
line = "some text"
|
||||||
|
draw.text((100, 40), line, (0, 0, 0), font=ttf, align='left')
|
||||||
|
del draw
|
||||||
|
|
||||||
def test_multiline_size(self):
|
def test_multiline_size(self):
|
||||||
ttf = self.get_font()
|
ttf = self.get_font()
|
||||||
im = Image.new(mode='RGB', size=(300, 100))
|
im = Image.new(mode='RGB', size=(300, 100))
|
||||||
|
@ -494,5 +504,6 @@ class TestImageFont(PillowTestCase):
|
||||||
class TestImageFont_RaqmLayout(TestImageFont):
|
class TestImageFont_RaqmLayout(TestImageFont):
|
||||||
LAYOUT_ENGINE = ImageFont.LAYOUT_RAQM
|
LAYOUT_ENGINE = ImageFont.LAYOUT_RAQM
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user