|
9 | 9 | from matplotlib.font_manager import (
|
10 | 10 | findfont, FontProperties, fontManager, json_dump, json_load, get_font,
|
11 | 11 | get_fontconfig_fonts, is_opentype_cff_font)
|
12 |
| -from matplotlib import rc_context |
| 12 | +from matplotlib import pyplot as plt, rc_context |
13 | 13 |
|
14 | 14 | has_fclist = shutil.which('fc-list') is not None
|
15 | 15 |
|
@@ -96,3 +96,19 @@ def test_hinting_factor(factor):
|
96 | 96 | # Check that hinting only changes text layout by a small (10%) amount.
|
97 | 97 | np.testing.assert_allclose(hinted_font.get_width_height(), expected,
|
98 | 98 | rtol=0.1)
|
| 99 | + |
| 100 | + |
| 101 | +@pytest.mark.xfail(not os.environ.get("TRAVIS"), reason="Font may be missing.") |
| 102 | +def test_find_ttc(): |
| 103 | + fp = FontProperties(family=["WenQuanYi Zen Hei"]) |
| 104 | + font = findfont(fp) |
| 105 | + assert os.path.basename(font) == "wqy-zenhei.ttc" |
| 106 | + |
| 107 | + fig, ax = plt.subplots() |
| 108 | + ax.text(.5, .5, "\N{KANGXI RADICAL DRAGON}", fontproperties=fp) |
| 109 | + fig.savefig(six.BytesIO(), format="raw") |
| 110 | + fig.savefig(six.BytesIO(), format="svg") |
| 111 | + with pytest.raises(RuntimeError): |
| 112 | + fig.savefig(six.BytesIO(), format="pdf") |
| 113 | + with pytest.raises(RuntimeError): |
| 114 | + fig.savefig(six.BytesIO(), format="ps") |
0 commit comments