当前位置: 首页>>代码示例>>Python>>正文


Python matplotlib.afm方法代码示例

本文整理汇总了Python中matplotlib.afm方法的典型用法代码示例。如果您正苦于以下问题:Python matplotlib.afm方法的具体用法?Python matplotlib.afm怎么用?Python matplotlib.afm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib的用法示例。


在下文中一共展示了matplotlib.afm方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: writeFonts

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import afm [as 别名]
def writeFonts(self):
        fonts = {}
        for filename, Fx in self.fontNames.iteritems():
            matplotlib.verbose.report('Embedding font %s' % filename, 'debug')
            if filename.endswith('.afm'):
                # from pdf.use14corefonts
                matplotlib.verbose.report('Writing AFM font', 'debug')
                fonts[Fx] = self._write_afm_font(filename)
            elif filename in self.dviFontInfo:
                # a Type 1 font from a dvi file; the filename is really the TeX name
                matplotlib.verbose.report('Writing Type-1 font', 'debug')
                fonts[Fx] = self.embedTeXFont(filename, self.dviFontInfo[filename])
            else:
                # a normal TrueType font
                matplotlib.verbose.report('Writing TrueType font', 'debug')
                realpath, stat_key = get_realpath_and_stat(filename)
                chars = self.used_characters.get(stat_key)
                if chars is not None and len(chars[1]):
                    fonts[Fx] = self.embedTTF(realpath, chars[1])
        self.writeObject(self.fontObject, fonts) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:22,代码来源:backend_pdf.py

示例2: _get_font_afm

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import afm [as 别名]
def _get_font_afm(self, prop):
        key = hash(prop)
        font = self.afm_font_cache.get(key)
        if font is None:
            filename = findfont(
                prop, fontext='afm', directory=self.file._core14fontdir)
            if filename is None:
                filename = findfont(
                    "Helvetica", fontext='afm',
                    directory=self.file._core14fontdir)
            font = self.afm_font_cache.get(filename)
            if font is None:
                with open(filename, 'rb') as fh:
                    font = AFM(fh)
                    self.afm_font_cache[filename] = font
            self.afm_font_cache[key] = font
        return font 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:19,代码来源:backend_pdf.py

示例3: writeFonts

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import afm [as 别名]
def writeFonts(self):
        fonts = {}
        for filename, Fx in six.iteritems(self.fontNames):
            matplotlib.verbose.report('Embedding font %s' % filename, 'debug')
            if filename.endswith('.afm'):
                # from pdf.use14corefonts
                matplotlib.verbose.report('Writing AFM font', 'debug')
                fonts[Fx] = self._write_afm_font(filename)
            elif filename in self.dviFontInfo:
                # a Type 1 font from a dvi file;
                # the filename is really the TeX name
                matplotlib.verbose.report('Writing Type-1 font', 'debug')
                fonts[Fx] = self.embedTeXFont(filename,
                                              self.dviFontInfo[filename])
            else:
                # a normal TrueType font
                matplotlib.verbose.report('Writing TrueType font', 'debug')
                realpath, stat_key = get_realpath_and_stat(filename)
                chars = self.used_characters.get(stat_key)
                if chars is not None and len(chars[1]):
                    fonts[Fx] = self.embedTTF(realpath, chars[1])
        self.writeObject(self.fontObject, fonts) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:24,代码来源:backend_pdf.py

示例4: fontName

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import afm [as 别名]
def fontName(self, fontprop):
        """
        Select a font based on fontprop and return a name suitable for
        Op.selectfont. If fontprop is a string, it will be interpreted
        as the filename (or dvi name) of the font.
        """

        if is_string_like(fontprop):
            filename = fontprop
        elif rcParams['pdf.use14corefonts']:
            filename = findfont(
                fontprop, fontext='afm', directory=self._core14fontdir)
            if filename is None:
                filename = findfont(
                    "Helvetica", fontext='afm', directory=self._core14fontdir)
        else:
            filename = findfont(fontprop)

        Fx = self.fontNames.get(filename)
        if Fx is None:
            Fx = Name('F%d' % self.nextFont)
            self.fontNames[filename] = Fx
            self.nextFont += 1
            matplotlib.verbose.report(
                'Assigning font %s = %s' % (Fx, filename),
                'debug')

        return Fx 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:30,代码来源:backend_pdf.py

示例5: fontName

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import afm [as 别名]
def fontName(self, fontprop):
        """
        Select a font based on fontprop and return a name suitable for
        Op.selectfont. If fontprop is a string, it will be interpreted
        as the filename (or dvi name) of the font.
        """

        if is_string_like(fontprop):
            filename = fontprop
        elif rcParams['pdf.use14corefonts']:
            filename = findfont(
                fontprop, fontext='afm', directory=self._core14fontdir)
            if filename is None:
                filename = findfont(
                    "Helvetica", fontext='afm', directory=self._core14fontdir)
        else:
            filename = findfont(fontprop)

        Fx = self.fontNames.get(filename)
        if Fx is None:
            Fx = Name('F%d' % self.nextFont)
            self.fontNames[filename] = Fx
            self.nextFont += 1
            matplotlib.verbose.report(
                'Assigning font %s = %r' % (Fx, filename),
                'debug')

        return Fx 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:30,代码来源:backend_pdf.py

示例6: test_afm_kerning

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import afm [as 别名]
def test_afm_kerning():
    from matplotlib.afm import AFM
    from matplotlib.font_manager import findfont

    fn = findfont("Helvetica", fontext="afm")
    with open(fn, 'rb') as fh:
        afm = AFM(fh)
    assert afm.string_width_height('VAVAVAVAVAVA') == (7174.0, 718) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:10,代码来源:test_text.py


注:本文中的matplotlib.afm方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。