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


Python matplotlib.dviread方法代码示例

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


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

示例1: tex_font_mapping

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import dviread [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: embedTeXFont

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import dviread [as 别名]
def embedTeXFont(self, texname, fontinfo):
        matplotlib.verbose.report(
            'Embedding TeX font ' + texname + ' - fontinfo=' + repr(fontinfo.__dict__),
            'debug')

        # Widths
        widthsObject = self.reserveObject('font widths')
        self.writeObject(widthsObject, fontinfo.dvifont.widths)

        # Font dictionary
        fontdictObject = self.reserveObject('font dictionary')
        fontdict = {
            'Type':      Name('Font'),
            'Subtype':   Name('Type1'),
            'FirstChar': 0,
            'LastChar':  len(fontinfo.dvifont.widths) - 1,
            'Widths':    widthsObject,
            }

        # Encoding (if needed)
        if fontinfo.encodingfile is not None:
            enc = dviread.Encoding(fontinfo.encodingfile)
            differencesArray = [ Name(ch) for ch in enc ]
            differencesArray = [ 0 ] + differencesArray
            fontdict['Encoding'] = \
                { 'Type': Name('Encoding'),
                  'Differences': differencesArray }

        # If no file is specified, stop short
        if fontinfo.fontfile is None:
            warnings.warn(
                'Because of TeX configuration (pdftex.map, see updmap ' +
                'option pdftexDownloadBase14) the font %s ' % fontinfo.basefont +
                'is not embedded. This is deprecated as of PDF 1.5 ' +
                'and it may cause the consumer application to show something ' +
                'that was not intended.')
            fontdict['BaseFont'] = Name(fontinfo.basefont)
            self.writeObject(fontdictObject, fontdict)
            return fontdictObject

        # We have a font file to embed - read it in and apply any effects
        t1font = type1font.Type1Font(fontinfo.fontfile)
        if fontinfo.effects:
            t1font = t1font.transform(fontinfo.effects)
        fontdict['BaseFont'] = Name(t1font.prop['FontName'])

        # Font descriptors may be shared between differently encoded
        # Type-1 fonts, so only create a new descriptor if there is no
        # existing descriptor for this font.
        effects = (fontinfo.effects.get('slant', 0.0), fontinfo.effects.get('extend', 1.0))
        fontdesc = self.type1Descriptors.get((fontinfo.fontfile, effects))
        if fontdesc is None:
            fontdesc = self.createType1Descriptor(t1font, fontinfo.fontfile)
            self.type1Descriptors[(fontinfo.fontfile, effects)] = fontdesc
        fontdict['FontDescriptor'] = fontdesc

        self.writeObject(fontdictObject, fontdict)
        return fontdictObject 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:60,代码来源:backend_pdf.py

示例3: embedTeXFont

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import dviread [as 别名]
def embedTeXFont(self, texname, fontinfo):
        msg = ('Embedding TeX font ' + texname + ' - fontinfo=' +
               repr(fontinfo.__dict__))
        matplotlib.verbose.report(msg, 'debug')

        # Widths
        widthsObject = self.reserveObject('font widths')
        self.writeObject(widthsObject, fontinfo.dvifont.widths)

        # Font dictionary
        fontdictObject = self.reserveObject('font dictionary')
        fontdict = {
            'Type':      Name('Font'),
            'Subtype':   Name('Type1'),
            'FirstChar': 0,
            'LastChar':  len(fontinfo.dvifont.widths) - 1,
            'Widths':    widthsObject,
            }

        # Encoding (if needed)
        if fontinfo.encodingfile is not None:
            enc = dviread.Encoding(fontinfo.encodingfile)
            differencesArray = [Name(ch) for ch in enc]
            differencesArray = [0] + differencesArray
            fontdict['Encoding'] = \
                {'Type': Name('Encoding'),
                 'Differences': differencesArray}

        # If no file is specified, stop short
        if fontinfo.fontfile is None:
            msg = ('Because of TeX configuration (pdftex.map, see updmap '
                   'option pdftexDownloadBase14) the font {0} is not '
                   'embedded. This is deprecated as of PDF 1.5 and it may '
                   'cause the consumer application to show something that '
                   'was not intended.').format(fontinfo.basefont)
            warnings.warn(msg)
            fontdict['BaseFont'] = Name(fontinfo.basefont)
            self.writeObject(fontdictObject, fontdict)
            return fontdictObject

        # We have a font file to embed - read it in and apply any effects
        t1font = type1font.Type1Font(fontinfo.fontfile)
        if fontinfo.effects:
            t1font = t1font.transform(fontinfo.effects)
        fontdict['BaseFont'] = Name(t1font.prop['FontName'])

        # Font descriptors may be shared between differently encoded
        # Type-1 fonts, so only create a new descriptor if there is no
        # existing descriptor for this font.
        effects = (fontinfo.effects.get('slant', 0.0),
                   fontinfo.effects.get('extend', 1.0))
        fontdesc = self.type1Descriptors.get((fontinfo.fontfile, effects))
        if fontdesc is None:
            fontdesc = self.createType1Descriptor(t1font, fontinfo.fontfile)
            self.type1Descriptors[(fontinfo.fontfile, effects)] = fontdesc
        fontdict['FontDescriptor'] = fontdesc

        self.writeObject(fontdictObject, fontdict)
        return fontdictObject 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:61,代码来源:backend_pdf.py


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