1+ from io import BytesIO
2+ import os
13from pathlib import Path
24import shutil
35import sys
911from matplotlib .font_manager import (
1012 findfont , FontProperties , fontManager , json_dump , json_load , get_font ,
1113 get_fontconfig_fonts , is_opentype_cff_font )
12- from matplotlib import rc_context
14+ from matplotlib import pyplot as plt , rc_context
1315
1416has_fclist = shutil .which ('fc-list' ) is not None
1517
@@ -91,7 +93,7 @@ def test_hinting_factor(factor):
9193
9294
9395@pytest .mark .skipif (sys .platform != "win32" ,
94- reason = "Need Windows font to test against" )
96+ reason = "Need Windows font to test against" )
9597def test_utf16m_sfnt ():
9698 segoe_ui_semibold = None
9799 for f in fontManager .ttflist :
@@ -105,3 +107,20 @@ def test_utf16m_sfnt():
105107 # Check that we successfully read the "semibold" from the font's
106108 # sfnt table and set its weight accordingly
107109 assert segoe_ui_semibold .weight == "semibold"
110+
111+
112+ @pytest .mark .xfail (not (os .environ .get ("TRAVIS" ) and sys .platform == "linux" ),
113+ reason = "Font may be missing." )
114+ def test_find_ttc ():
115+ fp = FontProperties (family = ["WenQuanYi Zen Hei" ])
116+ font = findfont (fp )
117+ assert Path (font ).name == "wqy-zenhei.ttc"
118+
119+ fig , ax = plt .subplots ()
120+ ax .text (.5 , .5 , "\N{KANGXI RADICAL DRAGON} " , fontproperties = fp )
121+ fig .savefig (BytesIO (), format = "raw" )
122+ fig .savefig (BytesIO (), format = "svg" )
123+ with pytest .raises (RuntimeError ):
124+ fig .savefig (BytesIO (), format = "pdf" )
125+ with pytest .raises (RuntimeError ):
126+ fig .savefig (BytesIO (), format = "ps" )
0 commit comments