diff --git a/Tests/fonts/10x20-ISO8859-1.pcf b/Tests/fonts/10x20-ISO8859-1.pcf new file mode 100644 index 000000000..d0d7ed921 Binary files /dev/null and b/Tests/fonts/10x20-ISO8859-1.pcf differ diff --git a/Tests/fonts/LICENSE.txt b/Tests/fonts/LICENSE.txt index 223c2aecf..ee9daee59 100644 --- a/Tests/fonts/LICENSE.txt +++ b/Tests/fonts/LICENSE.txt @@ -4,3 +4,10 @@ NotoNastaliqUrdu-Regular.ttf: (from https://github.com/googlei18n/noto-fonts) All Noto fonts are published under the SIL Open Font License (OFL) v1.1 (http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL), which allows you to copy, modify, and redistribute them if you need to. + + +10x20-ISO8859-1.pcf + +(from https://packages.ubuntu.com/xenial/xfonts-base) + +"Public domain font. Share and enjoy." diff --git a/Tests/fonts/helvO18.pcf b/Tests/fonts/helvO18.pcf deleted file mode 100644 index f5e68ae9c..000000000 Binary files a/Tests/fonts/helvO18.pcf and /dev/null differ diff --git a/Tests/images/high_ascii_chars.png b/Tests/images/high_ascii_chars.png index fc9ab8401..81cf810af 100644 Binary files a/Tests/images/high_ascii_chars.png and b/Tests/images/high_ascii_chars.png differ diff --git a/Tests/images/test_draw_pbm_target.png b/Tests/images/test_draw_pbm_target.png new file mode 100644 index 000000000..38323f45a Binary files /dev/null and b/Tests/images/test_draw_pbm_target.png differ diff --git a/Tests/test_font_pcf.py b/Tests/test_font_pcf.py index 90e204303..87a3ea067 100644 --- a/Tests/test_font_pcf.py +++ b/Tests/test_font_pcf.py @@ -5,7 +5,7 @@ from PIL import ImageFont, ImageDraw codecs = dir(Image.core) -fontname = "Tests/fonts/helvO18.pcf" +fontname = "Tests/fonts/10x20-ISO8859-1.pcf" message = "hello, world" @@ -20,7 +20,8 @@ class TestFontPcf(PillowTestCase): with open(fontname, "rb") as test_file: font = PcfFontFile.PcfFontFile(test_file) self.assertIsInstance(font, FontFile.FontFile) - self.assertEqual(len([_f for _f in font.glyph if _f]), 192) + #check the number of characters in the font + self.assertEqual(len([_f for _f in font.glyph if _f]), 223) tempname = self.tempfile("temp.pil") self.addCleanup(self.delete_tempfile, tempname[:-4]+'.pbm') @@ -34,25 +35,26 @@ class TestFontPcf(PillowTestCase): with open("Tests/images/flower.jpg", "rb") as fp: self.assertRaises(SyntaxError, PcfFontFile.PcfFontFile, fp) - def xtest_draw(self): - + def test_draw(self): tempname = self.save_font() font = ImageFont.load(tempname) - image = Image.new("L", font.getsize(message), "white") - draw = ImageDraw.Draw(image) - draw.text((0, 0), message, font=font) - # assert_signature(image, "7216c60f988dea43a46bb68321e3c1b03ec62aee") + im = Image.new("L", (130,30), "white") + draw = ImageDraw.Draw(im) + draw.text((0, 0), message, 'black', font=font) + with Image.open('Tests/images/test_draw_pbm_target.png') as target: + self.assert_image_similar(im, target, 0) + def _test_high_characters(self, message): tempname = self.save_font() font = ImageFont.load(tempname) - image = Image.new("L", font.getsize(message), "white") - draw = ImageDraw.Draw(image) - draw.text((0, 0), message, font=font) + im = Image.new("L", (750,30) , "white") + draw = ImageDraw.Draw(im) + draw.text((0, 0), message, "black", font=font) + with Image.open('Tests/images/high_ascii_chars.png') as target: + self.assert_image_similar(im, target, 0) - compare = Image.open('Tests/images/high_ascii_chars.png') - self.assert_image_equal(image, compare) def test_high_characters(self): message = "".join(chr(i+1) for i in range(140, 232))