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


Python TTFont.addObjects方法代码示例

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


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

示例1: testParallelConstruction

# 需要导入模块: from reportlab.pdfbase.ttfonts import TTFont [as 别名]
# 或者: from reportlab.pdfbase.ttfonts.TTFont import addObjects [as 别名]
 def testParallelConstruction(self):
     "Test that TTFont can be used for different documents at the same time"
     doc1 = PDFDocument()
     doc2 = PDFDocument()
     font = TTFont("TestFont", "luxiserif.ttf")
     self.assertEquals(font.splitString("ab", doc1), [(0, "\0\1")])
     self.assertEquals(font.splitString("b", doc2), [(0, "\0")])
     font.addObjects(doc1)
     self.assertEquals(font.splitString("c", doc2), [(0, "\1")])
     font.addObjects(doc2)
开发者ID:eaudeweb,项目名称:naaya,代码行数:12,代码来源:test_pdfbase_ttfonts.py

示例2: testParallelConstruction

# 需要导入模块: from reportlab.pdfbase.ttfonts import TTFont [as 别名]
# 或者: from reportlab.pdfbase.ttfonts.TTFont import addObjects [as 别名]
 def testParallelConstruction(self):
     "Test that TTFont can be used for different documents at the same time"
     doc1 = PDFDocument()
     doc2 = PDFDocument()
     font = TTFont("TestFont", "luxiserif.ttf")
     self.assertEquals(font.splitString(u'hello ', doc1), [(0, 'hello ')])
     self.assertEquals(font.splitString(u'hello ', doc2), [(0, 'hello ')])
     self.assertEquals(font.splitString(u'\u0410\u0411'.encode('UTF-8'), doc1), [(0, '\x80\x81')])
     self.assertEquals(font.splitString(u'\u0412'.encode('UTF-8'), doc2), [(0, '\x80')])
     font.addObjects(doc1)
     self.assertEquals(font.splitString(u'\u0413'.encode('UTF-8'), doc2), [(0, '\x81')])
     font.addObjects(doc2)
开发者ID:ShaulBarkan,项目名称:PRION,代码行数:14,代码来源:test_pdfbase_ttfonts.py

示例3: no_longer_testAddObjectsResets

# 需要导入模块: from reportlab.pdfbase.ttfonts import TTFont [as 别名]
# 或者: from reportlab.pdfbase.ttfonts.TTFont import addObjects [as 别名]
 def no_longer_testAddObjectsResets(self):
     "Test that TTFont.addObjects resets the font"
     # Actually generate some subsets
     doc = PDFDocument()
     font = TTFont("Vera", "Vera.ttf")
     font.splitString('a', doc)            # create some subset
     doc = PDFDocument()
     font.addObjects(doc)
     self.assertEquals(font.frozen, 0)
     self.assertEquals(font.nextCode, 0)
     self.assertEquals(font.subsets, [])
     self.assertEquals(font.assignments, {})
     font.splitString('ba', doc)           # should work
开发者ID:Distrotech,项目名称:reportlab,代码行数:15,代码来源:test_pdfbase_ttfonts.py

示例4: testParallelConstruction

# 需要导入模块: from reportlab.pdfbase.ttfonts import TTFont [as 别名]
# 或者: from reportlab.pdfbase.ttfonts.TTFont import addObjects [as 别名]
 def testParallelConstruction(self):
     "Test that TTFont can be used for different documents at the same time"
     ttfAsciiReadable = rl_config.ttfAsciiReadable
     try:
         rl_config.ttfAsciiReadable = 1
         doc1 = PDFDocument()
         doc2 = PDFDocument()
         font = TTFont("Vera", "Vera.ttf")
         self.assertEquals(font.splitString('hello ', doc1), [(0, b'hello ')])
         self.assertEquals(font.splitString('hello ', doc2), [(0, b'hello ')])
         self.assertEquals(font.splitString(u'\u0410\u0411'.encode('UTF-8'), doc1), [(0, b'\x80\x81')])
         self.assertEquals(font.splitString(u'\u0412'.encode('UTF-8'), doc2), [(0, b'\x80')])
         font.addObjects(doc1)
         self.assertEquals(font.splitString(u'\u0413'.encode('UTF-8'), doc2), [(0, b'\x81')])
         font.addObjects(doc2)
     finally:
         rl_config.ttfAsciiReadable = ttfAsciiReadable
开发者ID:Distrotech,项目名称:reportlab,代码行数:19,代码来源:test_pdfbase_ttfonts.py

示例5: testAddObjects

# 需要导入模块: from reportlab.pdfbase.ttfonts import TTFont [as 别名]
# 或者: from reportlab.pdfbase.ttfonts.TTFont import addObjects [as 别名]
 def testAddObjects(self):
     "Test TTFont.addObjects"
     # Actually generate some subsets
     doc = PDFDocument()
     font = TTFont("TestFont", "luxiserif.ttf")
     font.splitString('a', doc)            # create some subset
     internalName = font.getSubsetInternalName(0, doc)[1:]
     font.addObjects(doc)
     pdfFont = doc.idToObject[internalName]
     self.assertEquals(doc.idToObject['BasicFonts'].dict[internalName], pdfFont)
     self.assertEquals(pdfFont.Name, internalName)
     self.assertEquals(pdfFont.BaseFont, "AAAAAA+LuxiSerif")
     self.assertEquals(pdfFont.FirstChar, 0)
     self.assertEquals(pdfFont.LastChar, 127)
     self.assertEquals(len(pdfFont.Widths.sequence), 128)
     toUnicode = doc.idToObject[pdfFont.ToUnicode.name]
     self.assert_(toUnicode.content != "")
     fontDescriptor = doc.idToObject[pdfFont.FontDescriptor.name]
     self.assertEquals(fontDescriptor.dict['Type'], '/FontDescriptor')
开发者ID:ShaulBarkan,项目名称:PRION,代码行数:21,代码来源:test_pdfbase_ttfonts.py

示例6: testAddObjects

# 需要导入模块: from reportlab.pdfbase.ttfonts import TTFont [as 别名]
# 或者: from reportlab.pdfbase.ttfonts.TTFont import addObjects [as 别名]
 def testAddObjects(self):
     "Test TTFont.addObjects"
     # Actually generate some subsets
     ttfAsciiReadable = rl_config.ttfAsciiReadable
     try:
         rl_config.ttfAsciiReadable = 1
         doc = PDFDocument()
         font = TTFont("Vera", "Vera.ttf")
         font.splitString('a', doc)            # create some subset
         internalName = font.getSubsetInternalName(0, doc)[1:]
         font.addObjects(doc)
         pdfFont = doc.idToObject[internalName]
         self.assertEquals(doc.idToObject['BasicFonts'].dict[internalName], pdfFont)
         self.assertEquals(pdfFont.Name, internalName)
         self.assertEquals(pdfFont.BaseFont, "AAAAAA+BitstreamVeraSans-Roman")
         self.assertEquals(pdfFont.FirstChar, 0)
         self.assertEquals(pdfFont.LastChar, 127)
         self.assertEquals(len(pdfFont.Widths.sequence), 128)
         toUnicode = doc.idToObject[pdfFont.ToUnicode.name]
         self.assert_(toUnicode.content != "")
         fontDescriptor = doc.idToObject[pdfFont.FontDescriptor.name]
         self.assertEquals(fontDescriptor.dict['Type'], '/FontDescriptor')
     finally:
         rl_config.ttfAsciiReadable = ttfAsciiReadable
开发者ID:Distrotech,项目名称:reportlab,代码行数:26,代码来源:test_pdfbase_ttfonts.py

示例7: testAddObjectsEmpty

# 需要导入模块: from reportlab.pdfbase.ttfonts import TTFont [as 别名]
# 或者: from reportlab.pdfbase.ttfonts.TTFont import addObjects [as 别名]
 def testAddObjectsEmpty(self):
     "TTFont.addObjects should not fail when no characters were used"
     font = TTFont("Vera", "Vera.ttf")
     doc = PDFDocument()
     font.addObjects(doc)
开发者ID:Distrotech,项目名称:reportlab,代码行数:7,代码来源:test_pdfbase_ttfonts.py


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