本文整理汇总了Python中matplotlib.font_manager.fontManager.findfont函数的典型用法代码示例。如果您正苦于以下问题:Python findfont函数的具体用法?Python findfont怎么用?Python findfont使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了findfont函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_json_serialization
def test_json_serialization():
with tempfile.NamedTemporaryFile() as temp:
json_dump(fontManager, temp.name)
copy = json_load(temp.name)
with warnings.catch_warnings():
warnings.filterwarnings('ignore', 'findfont: Font family.*not found')
for prop in ({'family': 'STIXGeneral'},
{'family': 'Bitstream Vera Sans', 'weight': 700},
{'family': 'no such font family'}):
fp = FontProperties(**prop)
assert_equal(fontManager.findfont(fp, rebuild_if_missing=False),
copy.findfont(fp, rebuild_if_missing=False))
示例2: test_json_serialization
def test_json_serialization(tmpdir):
# Can't open a NamedTemporaryFile twice on Windows, so use a temporary
# directory instead.
path = Path(tmpdir, "fontlist.json")
json_dump(fontManager, path)
copy = json_load(path)
with warnings.catch_warnings():
warnings.filterwarnings('ignore', 'findfont: Font family.*not found')
for prop in ({'family': 'STIXGeneral'},
{'family': 'Bitstream Vera Sans', 'weight': 700},
{'family': 'no such font family'}):
fp = FontProperties(**prop)
assert (fontManager.findfont(fp, rebuild_if_missing=False) ==
copy.findfont(fp, rebuild_if_missing=False))
示例3: test_json_serialization
def test_json_serialization():
# on windows, we can't open a file twice, so save the name and unlink
# manually...
try:
name = None
with tempfile.NamedTemporaryFile(delete=False) as temp:
name = temp.name
json_dump(fontManager, name)
copy = json_load(name)
finally:
if name and os.path.exists(name):
os.remove(name)
with warnings.catch_warnings():
warnings.filterwarnings('ignore', 'findfont: Font family.*not found')
for prop in ({'family': 'STIXGeneral'},
{'family': 'Bitstream Vera Sans', 'weight': 700},
{'family': 'no such font family'}):
fp = FontProperties(**prop)
assert (fontManager.findfont(fp, rebuild_if_missing=False) ==
copy.findfont(fp, rebuild_if_missing=False))