|
13 | 13 | from matplotlib.font_manager import ( |
14 | 14 | findfont, FontProperties, fontManager, json_dump, json_load, get_font, |
15 | 15 | get_fontconfig_fonts, is_opentype_cff_font, fontManager as fm) |
16 | | -from matplotlib import rc_context |
| 16 | +from matplotlib import pyplot as plt, rc_context |
17 | 17 |
|
18 | 18 | if six.PY2: |
19 | 19 | from distutils.spawn import find_executable |
@@ -106,3 +106,19 @@ def test_hinting_factor(factor): |
106 | 106 | # Check that hinting only changes text layout by a small (10%) amount. |
107 | 107 | np.testing.assert_allclose(hinted_font.get_width_height(), expected, |
108 | 108 | rtol=0.1) |
| 109 | + |
| 110 | + |
| 111 | +@pytest.mark.xfail(not os.environ.get("TRAVIS"), reason="Font may be missing.") |
| 112 | +def test_find_ttc(): |
| 113 | + fp = FontProperties(family=["WenQuanYi Zen Hei"]) |
| 114 | + font = findfont(fp) |
| 115 | + assert os.path.basename(font) == "wqy-zenhei.ttc" |
| 116 | + |
| 117 | + fig, ax = plt.subplots() |
| 118 | + ax.text(.5, .5, "\N{KANGXI RADICAL DRAGON}", fontproperties=fp) |
| 119 | + fig.savefig(six.BytesIO(), format="raw") |
| 120 | + fig.savefig(six.BytesIO(), format="svg") |
| 121 | + with pytest.raises(RuntimeError): |
| 122 | + fig.savefig(six.BytesIO(), format="pdf") |
| 123 | + with pytest.raises(RuntimeError): |
| 124 | + fig.savefig(six.BytesIO(), format="ps") |
0 commit comments