@@ -856,6 +856,19 @@ def test_bitmap_font_stroke(layout_engine):
856
856
assert_image_similar_tofile (im , target , 0.03 )
857
857
858
858
859
+ @pytest .mark .parametrize ("embedded_color" , (False , True ))
860
+ def test_bitmap_blend (layout_engine , embedded_color ):
861
+ font = ImageFont .truetype (
862
+ "Tests/fonts/EBDTTestFont.ttf" , size = 64 , layout_engine = layout_engine
863
+ )
864
+
865
+ im = Image .new ("RGBA" , (128 , 96 ), "white" )
866
+ d = ImageDraw .Draw (im )
867
+ d .text ((16 , 16 ), "AA" , font = font , embedded_color = embedded_color , fill = "#8E2F52" )
868
+
869
+ assert_image_equal_tofile (im , "Tests/images/bitmap_font_blend.png" )
870
+
871
+
859
872
def test_standard_embedded_color (layout_engine ):
860
873
txt = "Hello World!"
861
874
ttf = ImageFont .truetype (FONT_PATH , 40 , layout_engine = layout_engine )
@@ -894,15 +907,15 @@ def test_float_coord(layout_engine, fontmode):
894
907
def test_cbdt (layout_engine ):
895
908
try :
896
909
font = ImageFont .truetype (
897
- "Tests/fonts/NotoColorEmoji .ttf" , size = 109 , layout_engine = layout_engine
910
+ "Tests/fonts/CBDTTestFont .ttf" , size = 64 , layout_engine = layout_engine
898
911
)
899
912
900
- im = Image .new ("RGB" , (150 , 150 ), "white" )
913
+ im = Image .new ("RGB" , (128 , 96 ), "white" )
901
914
d = ImageDraw .Draw (im )
902
915
903
- d .text ((10 , 10 ), "\U0001f469 " , font = font , embedded_color = True )
916
+ d .text ((16 , 16 ), "AB " , font = font , embedded_color = True )
904
917
905
- assert_image_similar_tofile (im , "Tests/images/cbdt_notocoloremoji .png" , 6.2 )
918
+ assert_image_equal_tofile (im , "Tests/images/cbdt .png" )
906
919
except OSError as e : # pragma: no cover
907
920
assert str (e ) in ("unimplemented feature" , "unknown file format" )
908
921
pytest .skip ("freetype compiled without libpng or CBDT support" )
@@ -911,17 +924,15 @@ def test_cbdt(layout_engine):
911
924
def test_cbdt_mask (layout_engine ):
912
925
try :
913
926
font = ImageFont .truetype (
914
- "Tests/fonts/NotoColorEmoji .ttf" , size = 109 , layout_engine = layout_engine
927
+ "Tests/fonts/CBDTTestFont .ttf" , size = 64 , layout_engine = layout_engine
915
928
)
916
929
917
- im = Image .new ("RGB" , (150 , 150 ), "white" )
930
+ im = Image .new ("RGB" , (128 , 96 ), "white" )
918
931
d = ImageDraw .Draw (im )
919
932
920
- d .text ((10 , 10 ), "\U0001f469 " , "black " , font = font )
933
+ d .text ((16 , 16 ), "AB " , "green " , font = font )
921
934
922
- assert_image_similar_tofile (
923
- im , "Tests/images/cbdt_notocoloremoji_mask.png" , 6.2
924
- )
935
+ assert_image_equal_tofile (im , "Tests/images/cbdt_mask.png" )
925
936
except OSError as e : # pragma: no cover
926
937
assert str (e ) in ("unimplemented feature" , "unknown file format" )
927
938
pytest .skip ("freetype compiled without libpng or CBDT support" )
0 commit comments