Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8181be3

Browse files
aitikguptatacaswell
authored andcommitted
Check if fallback font is available
1 parent dfa519b commit 8181be3

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

lib/matplotlib/tests/test_agg.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import io
2+
import pathlib
23

34
import numpy as np
45
from numpy.testing import assert_array_almost_equal
@@ -7,11 +8,12 @@
78

89

910
from matplotlib import (
10-
collections, path, pyplot as plt, transforms as mtransforms, rcParams)
11+
collections, path, pyplot as plt, transforms as mtransforms, rcParams,
12+
font_manager as fm
13+
)
1114
from matplotlib.backends.backend_agg import RendererAgg
1215
from matplotlib.figure import Figure
1316
from matplotlib.image import imread
14-
from matplotlib.path import Path
1517
from matplotlib.testing.decorators import image_comparison
1618
from matplotlib.transforms import IdentityTransform
1719

@@ -296,7 +298,7 @@ def chunk_limit_setup():
296298
gc.set_linewidth(1)
297299
gc.set_foreground('r')
298300
# make a Path
299-
p = Path(np.vstack((x, y)).T)
301+
p = path.Path(np.vstack((x, y)).T)
300302
# effectively disable path simplification (but leaving it "on")
301303
p.simplify_threshold = 0
302304

@@ -353,6 +355,10 @@ def test_chunksize_toobig_chunks(chunk_limit_setup):
353355

354356
@image_comparison(["font_fallback.png"])
355357
def test_font_fallback():
358+
fp = fm.FontProperties(family=["WenQuanYi Zen Hei"])
359+
if pathlib.Path(fm.findfont(fp)).name != "wqy-zenhei.ttc":
360+
pytest.skip("Font may be missing")
361+
356362
plt.rc('font', family=['DejaVu Sans', 'WenQuanYi Zen Hei'], size=15)
357363

358364
fig, ax = plt.subplots()

0 commit comments

Comments
 (0)