Created
January 23, 2014 18:30
-
-
Save wiredfool/8584125 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tester import * | |
from PIL import Image, FontFile, PcfFontFile | |
from PIL import ImageFont, ImageDraw | |
codecs = dir(Image.core) | |
if "zip_encoder" not in codecs or "zip_decoder" not in codecs: | |
skip("zlib support not available") | |
#fontname = "Tests/fonts/helvO18.pcf" | |
fontname = "Tests/fonts/7x13-ISO8859-5.pcf" | |
tempname = tempfile("temp.pil", "temp.pbm") | |
message = "hello, world" | |
def test_sanity(): | |
file = open(fontname, "rb") | |
font = PcfFontFile.PcfFontFile(file) | |
assert_true(isinstance(font, FontFile.FontFile)) | |
assert_equal(len([_f for _f in font.glyph if _f]), 192) | |
print (font.glyph) | |
font.save(tempname) | |
def test_draw(): | |
message = str("".join([chr(i+1) for i in range(223)])) | |
font = ImageFont.load(tempname) | |
image = Image.new("L", font.getsize(message), "white") | |
draw = ImageDraw.Draw(image) | |
draw.text((0, 0), message, font=font) | |
image.show() | |
# assert_signature(image, "7216c60f988dea43a46bb68321e3c1b03ec62aee") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment