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


Python dviread.PsfontsMap方法代码示例

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


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

示例1: tex_font_mapping

# 需要导入模块: from matplotlib import dviread [as 别名]
# 或者: from matplotlib.dviread import PsfontsMap [as 别名]
def tex_font_mapping(self, texfont):
        if self.tex_font_map is None:
            self.tex_font_map = \
                dviread.PsfontsMap(dviread.find_tex_file('pdftex.map'))
        return self.tex_font_map[texfont] 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:7,代码来源:backend_pdf.py

示例2: texFontMap

# 需要导入模块: from matplotlib import dviread [as 别名]
# 或者: from matplotlib.dviread import PsfontsMap [as 别名]
def texFontMap(self):
        # lazy-load texFontMap, it takes a while to parse
        # and usetex is a relatively rare use case
        return dviread.PsfontsMap(dviread.find_tex_file('pdftex.map')) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:6,代码来源:backend_pdf.py

示例3: dviFontName

# 需要导入模块: from matplotlib import dviread [as 别名]
# 或者: from matplotlib.dviread import PsfontsMap [as 别名]
def dviFontName(self, dvifont):
        """
        Given a dvi font object, return a name suitable for Op.selectfont.
        This registers the font information in self.dviFontInfo if not yet
        registered.
        """

        dvi_info = self.dviFontInfo.get(dvifont.texname)
        if dvi_info is not None:
            return dvi_info.pdfname

        tex_font_map = dviread.PsfontsMap(dviread.find_tex_file('pdftex.map'))
        psfont = tex_font_map[dvifont.texname]
        if psfont.filename is None:
            raise ValueError(
                "No usable font file found for {} (TeX: {}); "
                "the font may lack a Type-1 version"
                .format(psfont.psname, dvifont.texname))

        pdfname = Name('F%d' % self.nextFont)
        self.nextFont += 1
        _log.debug('Assigning font %s = %s (dvi)', pdfname, dvifont.texname)
        self.dviFontInfo[dvifont.texname] = types.SimpleNamespace(
            dvifont=dvifont,
            pdfname=pdfname,
            fontfile=psfont.filename,
            basefont=psfont.psname,
            encodingfile=psfont.encoding,
            effects=psfont.effects)
        return pdfname 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:32,代码来源:backend_pdf.py

示例4: test_PsfontsMap

# 需要导入模块: from matplotlib import dviread [as 别名]
# 或者: from matplotlib.dviread import PsfontsMap [as 别名]
def test_PsfontsMap():
    filename = os.path.join(
        os.path.dirname(__file__),
        'baseline_images', 'dviread', 'test.map')
    fontmap = dr.PsfontsMap(filename)
    # Check all properties of a few fonts
    for n in [1, 2, 3, 4, 5]:
        key = 'TeXfont%d' % n
        entry = fontmap[key]
        assert_equal(entry.texname, key)
        assert_equal(entry.psname, 'PSfont%d' % n)
        if n not in [3, 5]:
            assert_equal(entry.encoding, 'font%d.enc' % n)
        elif n == 3:
            assert_equal(entry.encoding, 'enc3.foo')
        # We don't care about the encoding of TeXfont5, which specifies
        # multiple encodings.
        if n not in [1, 5]:
            assert_equal(entry.filename, 'font%d.pfa' % n)
        else:
            assert_equal(entry.filename, 'font%d.pfb' % n)
        if n == 4:
            assert_equal(entry.effects, {'slant': -0.1, 'extend': 2.2})
        else:
            assert_equal(entry.effects, {})
    # Some special cases
    entry = fontmap['TeXfont6']
    assert_equal(entry.filename, None)
    assert_equal(entry.encoding, None)
    entry = fontmap['TeXfont7']
    assert_equal(entry.filename, None)
    assert_equal(entry.encoding, 'font7.enc')
    entry = fontmap['TeXfont8']
    assert_equal(entry.filename, 'font8.pfb')
    assert_equal(entry.encoding, None)
    entry = fontmap['TeXfont9']
    assert_equal(entry.filename, '/absolute/font9.pfb') 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:39,代码来源:test_dviread.py

示例5: tex_font_map

# 需要导入模块: from matplotlib import dviread [as 别名]
# 或者: from matplotlib.dviread import PsfontsMap [as 别名]
def tex_font_map(self):
        return dviread.PsfontsMap(dviread.find_tex_file('pdftex.map')) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:4,代码来源:textpath.py

示例6: _get_ps_font_and_encoding

# 需要导入模块: from matplotlib import dviread [as 别名]
# 或者: from matplotlib.dviread import PsfontsMap [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 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:34,代码来源:textpath.py

示例7: test_missing_psfont

# 需要导入模块: from matplotlib import dviread [as 别名]
# 或者: from matplotlib.dviread import PsfontsMap [as 别名]
def test_missing_psfont(monkeypatch):
    """An error is raised if a TeX font lacks a Type-1 equivalent"""
    from matplotlib import rc

    def psfont(*args, **kwargs):
        return dviread.PsFont(texname='texfont', psname='Some Font',
                              effects=None, encoding=None, filename=None)

    monkeypatch.setattr(dviread.PsfontsMap, '__getitem__', psfont)
    rc('text', usetex=True)
    fig, ax = plt.subplots()
    ax.text(0.5, 0.5, 'hello')
    with tempfile.TemporaryFile() as tmpfile, pytest.raises(ValueError):
        fig.savefig(tmpfile, format='svg') 
开发者ID:holzschu,项目名称:python3_ios,代码行数:16,代码来源:test_backend_svg.py

示例8: test_missing_psfont

# 需要导入模块: from matplotlib import dviread [as 别名]
# 或者: from matplotlib.dviread import PsfontsMap [as 别名]
def test_missing_psfont(monkeypatch):
    """An error is raised if a TeX font lacks a Type-1 equivalent"""
    def psfont(*args, **kwargs):
        return dviread.PsFont(texname='texfont', psname='Some Font',
                              effects=None, encoding=None, filename=None)

    monkeypatch.setattr(dviread.PsfontsMap, '__getitem__', psfont)
    rcParams['text.usetex'] = True
    fig, ax = plt.subplots()
    ax.text(0.5, 0.5, 'hello')
    with tempfile.TemporaryFile() as tmpfile, pytest.raises(ValueError):
        fig.savefig(tmpfile, format='pdf') 
开发者ID:holzschu,项目名称:python3_ios,代码行数:14,代码来源:test_backend_pdf.py

示例9: test_PsfontsMap

# 需要导入模块: from matplotlib import dviread [as 别名]
# 或者: from matplotlib.dviread import PsfontsMap [as 别名]
def test_PsfontsMap(monkeypatch):
    monkeypatch.setattr(dr, 'find_tex_file', lambda x: x)

    filename = str(Path(__file__).parent / 'baseline_images/dviread/test.map')
    fontmap = dr.PsfontsMap(filename)
    # Check all properties of a few fonts
    for n in [1, 2, 3, 4, 5]:
        key = b'TeXfont%d' % n
        entry = fontmap[key]
        assert entry.texname == key
        assert entry.psname == b'PSfont%d' % n
        if n not in [3, 5]:
            assert entry.encoding == b'font%d.enc' % n
        elif n == 3:
            assert entry.encoding == b'enc3.foo'
        # We don't care about the encoding of TeXfont5, which specifies
        # multiple encodings.
        if n not in [1, 5]:
            assert entry.filename == b'font%d.pfa' % n
        else:
            assert entry.filename == b'font%d.pfb' % n
        if n == 4:
            assert entry.effects == {'slant': -0.1, 'extend': 2.2}
        else:
            assert entry.effects == {}
    # Some special cases
    entry = fontmap[b'TeXfont6']
    assert entry.filename is None
    assert entry.encoding is None
    entry = fontmap[b'TeXfont7']
    assert entry.filename is None
    assert entry.encoding == b'font7.enc'
    entry = fontmap[b'TeXfont8']
    assert entry.filename == b'font8.pfb'
    assert entry.encoding is None
    entry = fontmap[b'TeXfont9']
    assert entry.filename == b'/absolute/font9.pfb'
    # Missing font
    with pytest.raises(KeyError) as exc:
        fontmap[b'no-such-font']
    assert 'no-such-font' in str(exc.value) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:43,代码来源:test_dviread.py

示例10: texFontMap

# 需要导入模块: from matplotlib import dviread [as 别名]
# 或者: from matplotlib.dviread import PsfontsMap [as 别名]
def texFontMap(self):
        # lazy-load texFontMap, it takes a while to parse
        # and usetex is a relatively rare use case
        if self._texFontMap is None:
            self._texFontMap = dviread.PsfontsMap(
                dviread.find_tex_file('pdftex.map'))

        return self._texFontMap 
开发者ID:alvarobartt,项目名称:twitter-stock-recommendation,代码行数:10,代码来源:backend_pdf.py


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