mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-24 17:06:16 +03:00
add test for {1bpp, 2bpp, 4bpp, 8bpp} bitmap fonts
This commit is contained in:
parent
28d313305a
commit
24f3d85a3e
BIN
Tests/fonts/DejaVuSans-24-1-stripped.ttf
Normal file
BIN
Tests/fonts/DejaVuSans-24-1-stripped.ttf
Normal file
Binary file not shown.
BIN
Tests/fonts/DejaVuSans-24-2-stripped.ttf
Normal file
BIN
Tests/fonts/DejaVuSans-24-2-stripped.ttf
Normal file
Binary file not shown.
BIN
Tests/fonts/DejaVuSans-24-4-stripped.ttf
Normal file
BIN
Tests/fonts/DejaVuSans-24-4-stripped.ttf
Normal file
Binary file not shown.
BIN
Tests/fonts/DejaVuSans-24-8-stripped.ttf
Normal file
BIN
Tests/fonts/DejaVuSans-24-8-stripped.ttf
Normal file
Binary file not shown.
|
@ -12,6 +12,9 @@ BungeeColor-Regular_colr_Windows.ttf, from https://github.com/djrrb/bungee
|
|||
All of the above 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.
|
||||
|
||||
|
||||
DejaVuSans-24-{1,2,4,8}-stripped.ttf are based on DejaVuSans.ttf converted using FontForge to add bitmap strikes and keep only the ASCII range.
|
||||
|
||||
|
||||
10x20-ISO8859-1.pcf, from https://packages.ubuntu.com/xenial/xfonts-base
|
||||
|
||||
"Public domain font. Share and enjoy."
|
||||
|
|
BIN
Tests/images/bitmap_font_1.png
Normal file
BIN
Tests/images/bitmap_font_1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 481 B |
BIN
Tests/images/bitmap_font_2.png
Normal file
BIN
Tests/images/bitmap_font_2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 661 B |
BIN
Tests/images/bitmap_font_4.png
Normal file
BIN
Tests/images/bitmap_font_4.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
BIN
Tests/images/bitmap_font_8.png
Normal file
BIN
Tests/images/bitmap_font_8.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
|
@ -2,7 +2,7 @@ import pytest
|
|||
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
|
||||
from .helper import assert_image_similar
|
||||
from .helper import assert_image_equal_tofile, assert_image_similar, skip_unless_feature
|
||||
|
||||
image_font_installed = True
|
||||
try:
|
||||
|
@ -41,3 +41,21 @@ def test_similar():
|
|||
font=font_outline,
|
||||
)
|
||||
assert_image_similar(im_bitmap, im_outline, 4)
|
||||
|
||||
|
||||
@skip_unless_feature("freetype2")
|
||||
@pytest.mark.parametrize("bpp", (1, 2, 4, 8))
|
||||
def test_bitmap_font(bpp):
|
||||
text = "Bitmap Font"
|
||||
target = f"Tests/images/bitmap_font_{bpp}.png"
|
||||
font = ImageFont.truetype(
|
||||
f"Tests/fonts/DejaVuSans-24-{bpp}-stripped.ttf",
|
||||
24,
|
||||
layout_engine=ImageFont.LAYOUT_BASIC,
|
||||
)
|
||||
|
||||
im = Image.new("RGB", (160, 35), "white")
|
||||
draw = ImageDraw.Draw(im)
|
||||
draw.text((2, 2), text, "black", font)
|
||||
|
||||
assert_image_equal_tofile(im, target)
|
||||
|
|
Loading…
Reference in New Issue
Block a user