本文整理匯總了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])
示例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])
示例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')
示例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