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

Skip to content

Commit 89439d2

Browse files
committed
Allow multiple Noto font types
1 parent 05ba9fc commit 89439d2

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

lib/matplotlib/tests/test_agg.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import io
22
from pathlib import Path
3+
import warnings
34

45
import numpy as np
56
from numpy.testing import assert_array_almost_equal
@@ -258,12 +259,18 @@ def test_draw_path_collection_error_handling():
258259

259260
@image_comparison(["font_fallback.png"])
260261
def test_font_fallback():
261-
fp = fm.FontProperties(family=["Noto Sans CJK JP"])
262+
fp = fm.FontProperties(family=["Noto Sans CJK SC", "Noto Sans CJK JP"])
262263
name = Path(fm.findfont(fp)).name
263264
if name not in ("NotoSansCJKsc-Regular.otf", "NotoSansCJK-Regular.ttc"):
264-
pytest.skip(f"Noto Sans CJK JP font may be missing, found: {name}")
265+
pytest.skip(f"Noto Sans CJK SC font may be missing, found: {name}")
265266

266-
plt.rc('font', family=['DejaVu Sans', 'Noto Sans CJK JP'], size=15)
267+
plt.rc('font', family=[
268+
'DejaVu Sans', 'Noto Sans CJK JP', 'Noto Sans CJK SC'
269+
], size=15)
267270

268271
fig, ax = plt.subplots()
269272
ax.text(0.25, 0.475, "There are 多个汉字 in between!")
273+
274+
with warnings.catch_warnings():
275+
warnings.filterwarnings('ignore', 'findfont: Font family.*not found')
276+
fig.canvas.draw()

0 commit comments

Comments
 (0)