@@ -32,6 +32,10 @@ def test_get_length(font: ImageFont.FreeTypeFont) -> None:
3232 assert ImageText .Text ("y" , font ).get_length () == 12
3333 assert ImageText .Text ("a" , font ).get_length () == 12
3434
35+ text = ImageText .Text ("\n " , font )
36+ with pytest .raises (ValueError , match = "can't measure length of multiline text" ):
37+ text .get_length ()
38+
3539
3640def test_get_bbox (font : ImageFont .FreeTypeFont ) -> None :
3741 assert ImageText .Text ("A" , font ).get_bbox () == (0 , 4 , 12 , 16 )
@@ -45,13 +49,20 @@ def test_standard_embedded_color(layout_engine: ImageFont.Layout) -> None:
4549 font = ImageFont .truetype (FONT_PATH , 40 , layout_engine = layout_engine )
4650 text = ImageText .Text ("Hello World!" , font )
4751 text .embed_color ()
52+ assert text .get_length () == 288
4853
4954 im = Image .new ("RGB" , (300 , 64 ), "white" )
5055 draw = ImageDraw .Draw (im )
5156 draw .text ((10 , 10 ), text , "#fa6" )
5257
5358 assert_image_similar_tofile (im , "Tests/images/standard_embedded.png" , 3.1 )
5459
60+ text = ImageText .Text ("" , mode = "1" )
61+ with pytest .raises (
62+ ValueError , match = "Embedded color supported only in RGB and RGBA modes"
63+ ):
64+ text .embed_color ()
65+
5566
5667@skip_unless_feature ("freetype2" )
5768def test_stroke () -> None :
0 commit comments