Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2219c1a

Browse files
committed
Consider extracted TTF fonts in font_names test
1 parent1220c51 commit2219c1a

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

‎lib/matplotlib/tests/test_font_manager.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
findfont,findSystemFonts,FontEntry,FontProperties,fontManager,
1616
json_dump,json_load,get_font,is_opentype_cff_font,
1717
MSUserFontDirectories,_get_fontconfig_fonts,ft2font,
18-
ttfFontProperty,cbook)
19-
frommatplotlibimportpyplotasplt,rc_context
18+
ttfFontProperty,cbook,_load_fontmanager)
19+
frommatplotlibimportpyplotasplt,rc_context,get_cachedir
2020

2121
has_fclist=shutil.which('fc-list')isnotNone
2222

@@ -297,18 +297,24 @@ def test_fontentry_dataclass_invalid_path():
297297

298298
@pytest.mark.skipif(sys.platform=='win32',reason='Linux or OS only')
299299
deftest_get_font_names():
300+
# Ensure fonts like 'mpltest' are not in cache
301+
new_fm=_load_fontmanager(try_read_cache=False)
302+
mpl_font_names=sorted(new_fm.get_font_names())
303+
300304
paths_mpl= [cbook._get_data_path('fonts',subdir)forsubdirin ['ttf']]
301305
fonts_mpl=findSystemFonts(paths_mpl,fontext='ttf')
302306
fonts_system=findSystemFonts(fontext='ttf')
307+
# TTF extracted and cached from TTC
308+
cached_fonts=findSystemFonts(get_cachedir(),fontext='ttf')
303309
ttf_fonts= []
304-
forpathinfonts_mpl+fonts_system:
310+
forpathinfonts_mpl+fonts_system+cached_fonts:
305311
try:
306312
font=ft2font.FT2Font(path)
307313
prop=ttfFontProperty(font)
308314
ttf_fonts.append(prop.name)
309315
except:
310316
pass
311317
available_fonts=sorted(list(set(ttf_fonts)))
312-
mpl_font_names=sorted(fontManager.get_font_names())
318+
313319
assertlen(available_fonts)==len(mpl_font_names)
314320
assertavailable_fonts==mpl_font_names

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp