@@ -304,40 +304,19 @@ def test_mathtext_fallback_to_cm_invalid():
304
304
mpl .rcParams ['mathtext.fallback_to_cm' ] = fallback
305
305
306
306
307
- def test_mathtext_fallback_cm ():
308
- mpl .font_manager .fontManager .addfont (
309
- os .path .join ((os .path .dirname (os .path .realpath (__file__ ))), 'mpltest.ttf' ))
310
- mpl .rcParams ["svg.fonttype" ] = 'none'
311
- mpl .rcParams ['mathtext.fontset' ] = 'custom'
312
- mpl .rcParams ['mathtext.rm' ] = 'mpltest'
313
- mpl .rcParams ['mathtext.it' ] = 'mpltest:italic'
314
- mpl .rcParams ['mathtext.bf' ] = 'mpltest:bold'
315
- mpl .rcParams ['mathtext.fallback' ] = 'cm'
316
-
317
- test_str = r'a$A\AA\breve\gimel$'
318
-
319
- buff = io .BytesIO ()
320
- fig , ax = plt .subplots ()
321
- fig .text (.5 , .5 , test_str , fontsize = 40 , ha = 'center' )
322
- fig .savefig (buff , format = "svg" )
323
- char_fonts = [
324
- line .split ("font-family:" )[- 1 ].split (";" )[0 ]
325
- for line in str (buff .getvalue ()).split (r"\n" ) if "tspan" in line
326
- ]
327
- assert char_fonts == [
328
- 'DejaVu Sans' , 'mpltest' , 'STIXGeneral' , 'cmr10' , 'STIXGeneral'
329
- ]
330
-
331
-
332
- def test_mathtext_fallback_stix ():
307
+ @pytest .mark .parametrize (
308
+ "fallback,fontlist" ,
309
+ [("cm" , ['DejaVu Sans' , 'mpltest' , 'STIXGeneral' , 'cmr10' , 'STIXGeneral' ]),
310
+ ("stix" , ['DejaVu Sans' , 'mpltest' , 'STIXGeneral' ])])
311
+ def test_mathtext_fallback_cm (fallback , fontlist ):
333
312
mpl .font_manager .fontManager .addfont (
334
313
os .path .join ((os .path .dirname (os .path .realpath (__file__ ))), 'mpltest.ttf' ))
335
314
mpl .rcParams ["svg.fonttype" ] = 'none'
336
315
mpl .rcParams ['mathtext.fontset' ] = 'custom'
337
316
mpl .rcParams ['mathtext.rm' ] = 'mpltest'
338
317
mpl .rcParams ['mathtext.it' ] = 'mpltest:italic'
339
318
mpl .rcParams ['mathtext.bf' ] = 'mpltest:bold'
340
- mpl .rcParams ['mathtext.fallback' ] = 'stix'
319
+ mpl .rcParams ['mathtext.fallback' ] = fallback
341
320
342
321
test_str = r'a$A\AA\breve\gimel$'
343
322
@@ -349,6 +328,5 @@ def test_mathtext_fallback_stix():
349
328
line .split ("font-family:" )[- 1 ].split (";" )[0 ]
350
329
for line in str (buff .getvalue ()).split (r"\n" ) if "tspan" in line
351
330
]
352
- assert char_fonts == [
353
- 'DejaVu Sans' , 'mpltest' , 'STIXGeneral'
354
- ]
331
+ assert char_fonts == fontlist
332
+ mpl .font_manager .fontManager .ttflist = mpl .font_manager .fontManager .ttflist [:- 1 ]
0 commit comments