From f1110889a1d1ac2d85912f387ebf8ed92d057bc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jouni=20K=2E=20Sepp=C3=A4nen?= Date: Sat, 21 Jan 2017 21:50:21 +0200 Subject: [PATCH 1/2] Add a newline separator in fc-list call Fixes #7906. --- lib/matplotlib/font_manager.py | 2 +- lib/matplotlib/tests/test_font_manager.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/font_manager.py b/lib/matplotlib/font_manager.py index fc29500e01b7..3e9a164d1458 100644 --- a/lib/matplotlib/font_manager.py +++ b/lib/matplotlib/font_manager.py @@ -281,7 +281,7 @@ def _call_fc_list(): 'This may take a moment.')) timer.start() try: - out = subprocess.check_output([str('fc-list'), '--format=%{file}']) + out = subprocess.check_output([str('fc-list'), '--format=%{file}\\n']) except (OSError, subprocess.CalledProcessError): return [] finally: diff --git a/lib/matplotlib/tests/test_font_manager.py b/lib/matplotlib/tests/test_font_manager.py index 51e529a4a341..7537bf5b8291 100644 --- a/lib/matplotlib/tests/test_font_manager.py +++ b/lib/matplotlib/tests/test_font_manager.py @@ -11,7 +11,7 @@ from matplotlib.font_manager import ( findfont, FontProperties, fontManager, json_dump, json_load, get_font, - is_opentype_cff_font, fontManager as fm) + get_fontconfig_fonts, is_opentype_cff_font, fontManager as fm) import os.path @@ -65,3 +65,7 @@ def test_otf(): with open(f, 'rb') as fd: res = fd.read(4) == b'OTTO' assert res == is_opentype_cff_font(f) + + +def test_get_fontconfig_fonts(): + assert len(get_fontconfig_fonts()) > 1 From d515587279861f7e34d2df0f46f18bac7be4300f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jouni=20K=2E=20Sepp=C3=A4nen?= Date: Sun, 22 Jan 2017 09:32:04 +0200 Subject: [PATCH 2/2] Skip fontconfig test on win32 --- lib/matplotlib/tests/test_font_manager.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/tests/test_font_manager.py b/lib/matplotlib/tests/test_font_manager.py index 7537bf5b8291..90785e8f4985 100644 --- a/lib/matplotlib/tests/test_font_manager.py +++ b/lib/matplotlib/tests/test_font_manager.py @@ -5,17 +5,15 @@ import six import os - +import sys import tempfile import warnings from matplotlib.font_manager import ( findfont, FontProperties, fontManager, json_dump, json_load, get_font, get_fontconfig_fonts, is_opentype_cff_font, fontManager as fm) -import os.path - - from matplotlib import rc_context +from matplotlib.testing.decorators import skipif def test_font_priority(): @@ -67,5 +65,6 @@ def test_otf(): assert res == is_opentype_cff_font(f) +@skipif(sys.platform == 'win32', reason='no fontconfig on Windows') def test_get_fontconfig_fonts(): assert len(get_fontconfig_fonts()) > 1