當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。