1313 assert_image_equal ,
1414 assert_image_similar ,
1515 assert_image_similar_tofile ,
16- is_mingw ,
1716 is_pypy ,
1817 is_win32 ,
1918 skip_unless_feature ,
@@ -661,7 +660,22 @@ def test_variation_get(self):
661660 {"name" : b"Size" , "minimum" : 0 , "maximum" : 300 , "default" : 0 }
662661 ]
663662
664- @pytest .mark .skipif (is_mingw (), reason = "epsilon too high for meaningful test" )
663+ def _check_text (self , font , path , epsilon ):
664+ im = Image .new ("RGB" , (100 , 75 ), "white" )
665+ d = ImageDraw .Draw (im )
666+ d .text ((10 , 10 ), "Text" , font = font , fill = "black" )
667+
668+ try :
669+ with Image .open (path ) as expected :
670+ assert_image_similar (im , expected , epsilon )
671+ except AssertionError :
672+ if "_adobe" in path :
673+ path = path .replace ("_adobe" , "_adobe_older_harfbuzz" )
674+ with Image .open (path ) as expected :
675+ assert_image_similar (im , expected , epsilon )
676+ else :
677+ raise
678+
665679 def test_variation_set_by_name (self ):
666680 font = self .get_font ()
667681
@@ -674,27 +688,18 @@ def test_variation_set_by_name(self):
674688 with pytest .raises (OSError ):
675689 font .set_variation_by_name ("Bold" )
676690
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-
685691 font = ImageFont .truetype ("Tests/fonts/AdobeVFPrototype.ttf" , 36 )
686- _check_text (font , "Tests/images/variation_adobe.png" , 11 )
692+ self . _check_text (font , "Tests/images/variation_adobe.png" , 11 )
687693 for name in ["Bold" , b"Bold" ]:
688694 font .set_variation_by_name (name )
689- _check_text (font , "Tests/images/variation_adobe_name.png" , 11 )
695+ self . _check_text (font , "Tests/images/variation_adobe_name.png" , 11 )
690696
691697 font = ImageFont .truetype ("Tests/fonts/TINY5x3GX.ttf" , 36 )
692- _check_text (font , "Tests/images/variation_tiny.png" , 40 )
698+ self . _check_text (font , "Tests/images/variation_tiny.png" , 40 )
693699 for name in ["200" , b"200" ]:
694700 font .set_variation_by_name (name )
695- _check_text (font , "Tests/images/variation_tiny_name.png" , 40 )
701+ self . _check_text (font , "Tests/images/variation_tiny_name.png" , 40 )
696702
697- @pytest .mark .skipif (is_mingw (), reason = "epsilon too high for meaningful test" )
698703 def test_variation_set_by_axes (self ):
699704 font = self .get_font ()
700705
@@ -707,21 +712,13 @@ def test_variation_set_by_axes(self):
707712 with pytest .raises (OSError ):
708713 font .set_variation_by_axes ([500 , 50 ])
709714
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-
718715 font = ImageFont .truetype ("Tests/fonts/AdobeVFPrototype.ttf" , 36 )
719716 font .set_variation_by_axes ([500 , 50 ])
720- _check_text (font , "Tests/images/variation_adobe_axes.png" , 5.1 )
717+ self . _check_text (font , "Tests/images/variation_adobe_axes.png" , 5.1 )
721718
722719 font = ImageFont .truetype ("Tests/fonts/TINY5x3GX.ttf" , 36 )
723720 font .set_variation_by_axes ([100 ])
724- _check_text (font , "Tests/images/variation_tiny_axes.png" , 32.5 )
721+ self . _check_text (font , "Tests/images/variation_tiny_axes.png" , 32.5 )
725722
726723
727724@skip_unless_feature ("raqm" )
0 commit comments