@@ -661,6 +661,22 @@ def test_variation_get(self):
661661 {"name" : b"Size" , "minimum" : 0 , "maximum" : 300 , "default" : 0 }
662662 ]
663663
664+ def _check_text (self , font , path , epsilon ):
665+ im = Image .new ("RGB" , (100 , 75 ), "white" )
666+ d = ImageDraw .Draw (im )
667+ d .text ((10 , 10 ), "Text" , font = font , fill = "black" )
668+
669+ try :
670+ with Image .open (path ) as expected :
671+ assert_image_similar (im , expected , epsilon )
672+ except AssertionError :
673+ if "_adobe" in path :
674+ path = path .replace ("_adobe" , "_adobe_older_harfbuzz" )
675+ with Image .open (path ) as expected :
676+ assert_image_similar (im , expected , epsilon )
677+ else :
678+ raise
679+
664680 @pytest .mark .skipif (is_mingw (), reason = "epsilon too high for meaningful test" )
665681 def test_variation_set_by_name (self ):
666682 font = self .get_font ()
@@ -674,25 +690,17 @@ def test_variation_set_by_name(self):
674690 with pytest .raises (OSError ):
675691 font .set_variation_by_name ("Bold" )
676692
677- def _check_text (font , path , epsilon ):
678- im = Image .new ("RGB" , (100 , 75 ), "white" )
679- d = ImageDraw .Draw (im )
680- d .text ((10 , 10 ), "Text" , font = font , fill = "black" )
681-
682- with Image .open (path ) as expected :
683- assert_image_similar (im , expected , epsilon )
684-
685693 font = ImageFont .truetype ("Tests/fonts/AdobeVFPrototype.ttf" , 36 )
686- _check_text (font , "Tests/images/variation_adobe.png" , 11 )
694+ self . _check_text (font , "Tests/images/variation_adobe.png" , 11 )
687695 for name in ["Bold" , b"Bold" ]:
688696 font .set_variation_by_name (name )
689- _check_text (font , "Tests/images/variation_adobe_name.png" , 11 )
697+ self . _check_text (font , "Tests/images/variation_adobe_name.png" , 11 )
690698
691699 font = ImageFont .truetype ("Tests/fonts/TINY5x3GX.ttf" , 36 )
692- _check_text (font , "Tests/images/variation_tiny.png" , 40 )
700+ self . _check_text (font , "Tests/images/variation_tiny.png" , 40 )
693701 for name in ["200" , b"200" ]:
694702 font .set_variation_by_name (name )
695- _check_text (font , "Tests/images/variation_tiny_name.png" , 40 )
703+ self . _check_text (font , "Tests/images/variation_tiny_name.png" , 40 )
696704
697705 @pytest .mark .skipif (is_mingw (), reason = "epsilon too high for meaningful test" )
698706 def test_variation_set_by_axes (self ):
@@ -707,21 +715,13 @@ def test_variation_set_by_axes(self):
707715 with pytest .raises (OSError ):
708716 font .set_variation_by_axes ([500 , 50 ])
709717
710- def _check_text (font , path , epsilon ):
711- im = Image .new ("RGB" , (100 , 75 ), "white" )
712- d = ImageDraw .Draw (im )
713- d .text ((10 , 10 ), "Text" , font = font , fill = "black" )
714-
715- with Image .open (path ) as expected :
716- assert_image_similar (im , expected , epsilon )
717-
718718 font = ImageFont .truetype ("Tests/fonts/AdobeVFPrototype.ttf" , 36 )
719719 font .set_variation_by_axes ([500 , 50 ])
720- _check_text (font , "Tests/images/variation_adobe_axes.png" , 5.1 )
720+ self . _check_text (font , "Tests/images/variation_adobe_axes.png" , 5.1 )
721721
722722 font = ImageFont .truetype ("Tests/fonts/TINY5x3GX.ttf" , 36 )
723723 font .set_variation_by_axes ([100 ])
724- _check_text (font , "Tests/images/variation_tiny_axes.png" , 32.5 )
724+ self . _check_text (font , "Tests/images/variation_tiny_axes.png" , 32.5 )
725725
726726
727727@skip_unless_feature ("raqm" )
0 commit comments