mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-09-21 11:28:58 +03:00
34 lines
972 B
Python
34 lines
972 B
Python
from tester import *
|
|
|
|
from PIL import Image
|
|
try:
|
|
from io import StringIO # python 3
|
|
except ImportError:
|
|
from StringIO import StringIO # python 2
|
|
|
|
try:
|
|
from PIL import ImageFont
|
|
ImageFont.core.getfont # check if freetype is available
|
|
except ImportError:
|
|
skip()
|
|
|
|
def test_sanity():
|
|
assert_match(ImageFont.core.freetype2_version, "\d+\.\d+\.\d+$")
|
|
|
|
def test_font_with_name():
|
|
font_name = "Tests/fonts/FreeMono.ttf"
|
|
font_size = 10
|
|
assert_no_exception(lambda: ImageFont.truetype(font_name, font_size))
|
|
|
|
def test_font_with_filelike():
|
|
font_name = "Tests/fonts/FreeMono.ttf"
|
|
font_filelike = StringIO.StringIO(open(font_name, 'rb').read())
|
|
font_size = 10
|
|
assert_no_exception(lambda: ImageFont.truetype(font_filelike, font_size))
|
|
|
|
def test_font_old_parameters():
|
|
font_name = "Tests/fonts/FreeMono.ttf"
|
|
font_size = 10
|
|
assert_warning(DeprecationWarning, lambda: ImageFont.truetype(filename=font_name, size=font_size))
|
|
|