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

Appearance settings

Commit 2219c1a

Browse filesBrowse files
committed
Consider extracted TTF fonts in font_names test
1 parent 1220c51 commit 2219c1a
Copy full SHA for 2219c1a

File tree

1 file changed

+10
-4
lines changed
Filter options

1 file changed

+10
-4
lines changed

‎lib/matplotlib/tests/test_font_manager.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_font_manager.py
+10-4Lines 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-
from matplotlib import pyplot as plt, rc_context
18+
ttfFontProperty, cbook, _load_fontmanager)
19+
from matplotlib import pyplot as plt, rc_context, get_cachedir
2020

2121
has_fclist = shutil.which('fc-list') is not None
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
def test_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) for subdir in ['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-
for path in fonts_mpl + fonts_system:
310+
for path in fonts_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
assert len(available_fonts) == len(mpl_font_names)
314320
assert available_fonts == mpl_font_names

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.