@@ -220,41 +220,39 @@ def test_TTF_GlyphMetrics(self):
220220
221221 def test_TTF_SizeText (self ):
222222 font = sdlttf .TTF_OpenFont (fontfile , 20 )
223- expected_w = 70
224- expected_h = [
225- 25 , # SDL2_ttf < 2.0.15
226- 24 , # SDL2_ttf == 2.0.15 w/ FreeType 2.9.1
227- 21 # SDL2_ttf == 2.0.15 w/ FreeType 2.10.1
228- ]
223+ min_expected_w = 69 # SDL2_ttf 2.0.18
224+ max_expected_w = 70 # SDL2_ttf <= 2.0.15
225+ min_expected_h = 21 # SDL2_ttf 2.0.15 with FreeType 2.10.1
226+ max_expected_h = 25 # SDL2_ttf < 2.0.15
229227 w , h = c_int (0 ), c_int (0 )
230228 sdlttf .TTF_SizeText (font , b"Hi there!" , byref (w ), byref (h ))
231- assert w .value == expected_w
232- assert h .value in expected_h
229+ assert w .value >= min_expected_w
230+ assert w .value <= max_expected_w
231+ assert h .value >= min_expected_h
232+ assert h .value <= max_expected_h
233233 sdlttf .TTF_CloseFont (font )
234234
235235 def test_TTF_SizeUTF8 (self ):
236236 font = sdlttf .TTF_OpenFont (fontfile , 20 )
237- expected_w = 73
238- expected_h = [
239- 25 , # SDL2_ttf < 2.0.15
240- 24 , # SDL2_ttf == 2.0.15 w/ FreeType 2.9.1
241- 21 # SDL2_ttf == 2.0.15 w/ FreeType 2.10.1
242- ]
237+ min_expected_w = 72 # SDL2_ttf 2.0.18
238+ max_expected_w = 73 # SDL2_ttf <= 2.0.15
239+ min_expected_h = 21 # SDL2_ttf 2.0.15 with FreeType 2.10.1
240+ max_expected_h = 25 # SDL2_ttf < 2.0.15
243241 w , h = c_int (0 ), c_int (0 )
244242 sdlttf .TTF_SizeUTF8 (font , u"Hï thère!" .encode ('utf-8' ), byref (w ), byref (h ))
245- assert w .value == expected_w
246- assert h .value in expected_h
243+ assert w .value >= min_expected_w
244+ assert w .value <= max_expected_w
245+ assert h .value >= min_expected_h
246+ assert h .value <= max_expected_h
247247 sdlttf .TTF_CloseFont (font )
248248
249249 @pytest .mark .xfail (reason = "Highly unstable under pytest for some reason" )
250250 def test_TTF_SizeUNICODE (self ):
251251 font = sdlttf .TTF_OpenFont (fontfile , 20 )
252- expected_w = 70
253- expected_h = [
254- 25 , # SDL2_ttf < 2.0.15
255- 24 , # SDL2_ttf == 2.0.15 w/ FreeType 2.9.1
256- 21 # SDL2_ttf == 2.0.15 w/ FreeType 2.10.1
257- ]
252+ min_expected_w = 69 # SDL2_ttf 2.0.18
253+ max_expected_w = 70 # SDL2_ttf <= 2.0.15
254+ min_expected_h = 21 # SDL2_ttf 2.0.15 with FreeType 2.10.1
255+ max_expected_h = 25 # SDL2_ttf < 2.0.15
258256 w , h = c_int (0 ), c_int (0 )
259257 teststr = u"Hi there!"
260258 strlen = len (teststr ) + 1 # +1 for byte-order mark
@@ -263,8 +261,10 @@ def test_TTF_SizeUNICODE(self):
263261 sdlttf .TTF_SizeUNICODE (font , strarr , byref (w ), byref (h ))
264262 print (list (strarr ))
265263 print ("w = {0}, h = {1}" .format (w .value , h .value ))
266- assert w .value == expected_w
267- assert h .value in expected_h
264+ assert w .value >= min_expected_w
265+ assert w .value <= max_expected_w
266+ assert h .value >= min_expected_h
267+ assert h .value <= max_expected_h
268268 sdlttf .TTF_CloseFont (font )
269269
270270 def test_TTF_Render_Solid (self ):
0 commit comments