add test for #3777

This commit is contained in:
nulano 2019-04-08 07:05:30 +02:00 committed by Andrew Murray
parent 92ff050bf9
commit 5f65f10191
4 changed files with 13 additions and 1 deletions

View File

@ -1,5 +1,5 @@
NotoNastaliqUrdu-Regular.ttf, from https://github.com/googlei18n/noto-fonts
NotoNastaliqUrdu-Regular.ttf and NotoSansSymbols-Regular.ttf, from https://github.com/googlei18n/noto-fonts
NotoSansJP-Thin.otf, from https://www.google.com/get/noto/help/cjk/
AdobeVFPrototype.ttf, from https://github.com/adobe-fonts/adobe-variable-font-prototype
TINY5x3GX.ttf, from http://velvetyne.fr/fonts/tiny

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 999 B

View File

@ -459,6 +459,18 @@ class TestImageFont(PillowTestCase):
with self.assertRaises(UnicodeEncodeError):
font.getsize(u"")
@unittest.skipIf(sys.platform.startswith('win32') and sys.version.startswith('2'),
"requires Python 3.x on Windows")
def test_unicode_render(self):
# issue #3777
text = u"A\u278A\U0001F12B"
ttf = ImageFont.truetype("Tests/fonts/NotoSansSymbols-Regular.ttf",
FONT_SIZE, layout_engine=self.LAYOUT_ENGINE)
img = Image.new("RGB", (100, 60))
d = ImageDraw.Draw(img)
d.text((10, 10), text, font=ttf)
self.assert_image_similar_tofile(img, "Tests/images/unicode_extended.png", self.metrics['textsize'])
def _test_fake_loading_font(self, path_to_fake, fontname):
# Make a copy of FreeTypeFont so we can patch the original
free_type_font = copy.deepcopy(ImageFont.FreeTypeFont)