|
12 | 12 | from matplotlib import dviread, pyplot as plt, checkdep_usetex, rcParams
|
13 | 13 | from matplotlib.cbook import _get_data_path
|
14 | 14 | from matplotlib.ft2font import FT2Font
|
| 15 | +from matplotlib.font_manager import findfont, FontProperties |
15 | 16 | from matplotlib.backends._backend_pdf_ps import get_glyphs_subset
|
16 | 17 | from matplotlib.backends.backend_pdf import PdfPages
|
17 | 18 |
|
@@ -43,12 +44,20 @@ def test_use14corefonts():
|
43 | 44 | ax.axhline(0.5, linewidth=0.5)
|
44 | 45 |
|
45 | 46 |
|
46 |
| -def test_type42(): |
47 |
| - rcParams['pdf.fonttype'] = 42 |
| 47 | +@pytest.mark.parametrize('fontname, fontfile', [ |
| 48 | + ('DejaVu Sans', 'DejaVuSans.ttf'), |
| 49 | + ('WenQuanYi Zen Hei', 'wqy-zenhei.ttc'), |
| 50 | +]) |
| 51 | +@pytest.mark.parametrize('fonttype', [3, 42]) |
| 52 | +def test_embed_fonts(fontname, fontfile, fonttype): |
| 53 | + if Path(findfont(FontProperties(family=[fontname]))).name != fontfile: |
| 54 | + pytest.skip(f'Font {fontname!r} may be missing') |
48 | 55 |
|
| 56 | + rcParams['pdf.fonttype'] = fonttype |
49 | 57 | fig, ax = plt.subplots()
|
50 | 58 | ax.plot([1, 2, 3])
|
51 |
| - fig.savefig(io.BytesIO()) |
| 59 | + ax.set_title('Axes Title', font=fontname) |
| 60 | + fig.savefig(io.BytesIO(), format='pdf') |
52 | 61 |
|
53 | 62 |
|
54 | 63 | def test_multipage_pagecount():
|
|
0 commit comments