當前位置: 首頁>>代碼示例>>Python>>正文


Python TTFont.getSubsetInternalName方法代碼示例

本文整理匯總了Python中reportlab.pdfbase.ttfonts.TTFont.getSubsetInternalName方法的典型用法代碼示例。如果您正苦於以下問題:Python TTFont.getSubsetInternalName方法的具體用法?Python TTFont.getSubsetInternalName怎麽用?Python TTFont.getSubsetInternalName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在reportlab.pdfbase.ttfonts.TTFont的用法示例。


在下文中一共展示了TTFont.getSubsetInternalName方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: testSubsetInternalName

# 需要導入模塊: from reportlab.pdfbase.ttfonts import TTFont [as 別名]
# 或者: from reportlab.pdfbase.ttfonts.TTFont import getSubsetInternalName [as 別名]
 def testSubsetInternalName(self):
     "Tests TTFont.getSubsetInternalName"
     doc = PDFDocument()
     font = TTFont("Vera", "Vera.ttf")
     # Actually generate some subsets
     text = b"".join(utf8(i) for i in range(513))
     font.splitString(text, doc)
     self.assertRaises(IndexError, font.getSubsetInternalName, -1, doc)
     self.assertRaises(IndexError, font.getSubsetInternalName, 3, doc)
     self.assertEquals(font.getSubsetInternalName(0, doc), "/F1+0")
     self.assertEquals(font.getSubsetInternalName(1, doc), "/F1+1")
     self.assertEquals(font.getSubsetInternalName(2, doc), "/F1+2")
     self.assertEquals(doc.delayedFonts, [font])
開發者ID:Distrotech,項目名稱:reportlab,代碼行數:15,代碼來源:test_pdfbase_ttfonts.py

示例2: testSubsetInternalName

# 需要導入模塊: from reportlab.pdfbase.ttfonts import TTFont [as 別名]
# 或者: from reportlab.pdfbase.ttfonts.TTFont import getSubsetInternalName [as 別名]
 def testSubsetInternalName(self):
     "Tests TTFont.getSubsetInternalName"
     doc = PDFDocument()
     font = TTFont("TestFont", "luxiserif.ttf")
     # Actually generate some subsets
     text = string.join(map(utf8, range(0, 513)), "")
     font.splitString(text, doc)
     self.assertRaises(IndexError, font.getSubsetInternalName, -1, doc)
     self.assertRaises(IndexError, font.getSubsetInternalName, 3, doc)
     self.assertEquals(font.getSubsetInternalName(0, doc), "/F1+0")
     self.assertEquals(font.getSubsetInternalName(1, doc), "/F1+1")
     self.assertEquals(font.getSubsetInternalName(2, doc), "/F1+2")
     self.assertEquals(doc.delayedFonts, [font])
開發者ID:ShaulBarkan,項目名稱:PRION,代碼行數:15,代碼來源:test_pdfbase_ttfonts.py

示例3: testAddObjects

# 需要導入模塊: from reportlab.pdfbase.ttfonts import TTFont [as 別名]
# 或者: from reportlab.pdfbase.ttfonts.TTFont import getSubsetInternalName [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

示例4: testAddObjects

# 需要導入模塊: from reportlab.pdfbase.ttfonts import TTFont [as 別名]
# 或者: from reportlab.pdfbase.ttfonts.TTFont import getSubsetInternalName [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


注:本文中的reportlab.pdfbase.ttfonts.TTFont.getSubsetInternalName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。