本文整理汇总了Python中matplotlib.font_manager.get_font方法的典型用法代码示例。如果您正苦于以下问题:Python font_manager.get_font方法的具体用法?Python font_manager.get_font怎么用?Python font_manager.get_font使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.font_manager
的用法示例。
在下文中一共展示了font_manager.get_font方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_agg_font
# 需要导入模块: from matplotlib import font_manager [as 别名]
# 或者: from matplotlib.font_manager import get_font [as 别名]
def _get_agg_font(self, prop):
"""
Get the font for text instance t, caching for efficiency
"""
fname = findfont(prop)
font = get_font(fname)
font.clear()
size = prop.get_size_in_points()
font.set_size(size, self.dpi)
return font
示例2: _get_font
# 需要导入模块: from matplotlib import font_manager [as 别名]
# 或者: from matplotlib.font_manager import get_font [as 别名]
def _get_font(self, prop):
fname = findfont(prop)
font = get_font(fname)
font.clear()
size = prop.get_size_in_points()
font.set_size(size, 72.0)
return font
示例3: _get_font_ttf
# 需要导入模块: from matplotlib import font_manager [as 别名]
# 或者: from matplotlib.font_manager import get_font [as 别名]
def _get_font_ttf(self, prop):
filename = findfont(prop)
font = get_font(filename)
font.clear()
font.set_size(prop.get_size_in_points(), 72)
return font
示例4: _get_font_ttf
# 需要导入模块: from matplotlib import font_manager [as 别名]
# 或者: from matplotlib.font_manager import get_font [as 别名]
def _get_font_ttf(self, prop):
fname = findfont(prop)
font = get_font(fname)
font.clear()
size = prop.get_size_in_points()
font.set_size(size, 72.0)
return font
示例5: _write_svgfonts
# 需要导入模块: from matplotlib import font_manager [as 别名]
# 或者: from matplotlib.font_manager import get_font [as 别名]
def _write_svgfonts(self):
if not rcParams['svg.fonttype'] == 'svgfont':
return
writer = self.writer
writer.start('defs')
for font_fname, chars in self._fonts.items():
font = get_font(font_fname)
font.set_size(72, 72)
sfnt = font.get_sfnt()
writer.start('font', id=sfnt[1, 0, 0, 4].decode("mac_roman"))
writer.element(
'font-face',
attrib={
'font-family': font.family_name,
'font-style': font.style_name.lower(),
'units-per-em': '72',
'bbox': ' '.join(
short_float_fmt(x / 64.0) for x in font.bbox)})
for char in chars:
glyph = font.load_char(char, flags=LOAD_NO_HINTING)
verts, codes = font.get_path()
path = Path(verts, codes)
path_data = self._convert_path(path)
# name = font.get_glyph_name(char)
writer.element(
'glyph',
d=path_data,
attrib={
# 'glyph-name': name,
'unicode': chr(char),
'horiz-adv-x':
short_float_fmt(glyph.linearHoriAdvance / 65536.0)})
writer.end('font')
writer.end('defs')
示例6: _get_font
# 需要导入模块: from matplotlib import font_manager [as 别名]
# 或者: from matplotlib.font_manager import get_font [as 别名]
def _get_font(self, font):
if font in self.fontmap:
basename = self.fontmap[font]
else:
basename = font
cached_font = self._fonts.get(basename)
if cached_font is None and os.path.exists(basename):
cached_font = get_font(basename)
self._fonts[basename] = cached_font
self._fonts[cached_font.postscript_name] = cached_font
self._fonts[cached_font.postscript_name.lower()] = cached_font
return cached_font
示例7: _get_font
# 需要导入模块: from matplotlib import font_manager [as 别名]
# 或者: from matplotlib.font_manager import get_font [as 别名]
def _get_font(self, prop):
"""
find a ttf font.
"""
fname = font_manager.findfont(prop)
font = get_font(fname)
font.set_size(self.FONT_SCALE, self.DPI)
return font
示例8: _get_ps_font_and_encoding
# 需要导入模块: from matplotlib import font_manager [as 别名]
# 或者: from matplotlib.font_manager import get_font [as 别名]
def _get_ps_font_and_encoding(texname):
tex_font_map = dviread.PsfontsMap(dviread.find_tex_file('pdftex.map'))
font_bunch = tex_font_map[texname]
if font_bunch.filename is None:
raise ValueError(
("No usable font file found for %s (%s). "
"The font may lack a Type-1 version.")
% (font_bunch.psname, texname))
font = get_font(font_bunch.filename)
for charmap_name, charmap_code in [("ADOBE_CUSTOM", 1094992451),
("ADOBE_STANDARD", 1094995778)]:
try:
font.select_charmap(charmap_code)
except (ValueError, RuntimeError):
pass
else:
break
else:
charmap_name = ""
warnings.warn("No supported encoding in font (%s)." %
font_bunch.filename)
if charmap_name == "ADOBE_STANDARD" and font_bunch.encoding:
enc0 = dviread.Encoding(font_bunch.encoding)
enc = {i: _get_adobe_standard_encoding().get(c, None)
for i, c in enumerate(enc0.encoding)}
else:
enc = {}
return font, enc
示例9: __init__
# 需要导入模块: from matplotlib import font_manager [as 别名]
# 或者: from matplotlib.font_manager import get_font [as 别名]
def __init__(self, default_font_prop, mathtext_backend):
Fonts.__init__(self, default_font_prop, mathtext_backend)
self.glyphd = {}
self._fonts = {}
filename = findfont(default_font_prop)
default_font = get_font(filename)
self._fonts['default'] = default_font
self._fonts['regular'] = default_font