[reportlab-users] Bug: Truetype not supported in para module
Dirk Holtwick
holtwick at spirito.de
Tue Mar 1 04:47:25 EST 2005
It seems that TrueType fonts are not supported in the platypus.para
module but in tne platypus.paragraph module. PostScript fonts don't
cause trouble. For illustration I added a complete example.
Yours Dirk
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
spirito GmbH
Dirk Holtwick
Grünstraße 6
D-47051 Duisburg
fon: +49-203-318-7777
fax: +49-1212-5-130-39-820
mbx: holtwick at spirito.de
web: http://www.spirito.de
GnuPG fingerprint (http://www.gnupg.org)
A5A1 54E1 C82E 02AD 4804 0547 66F4 3FB0 C790 EBAB
-------------- next part --------------
from reportlab.platypus import *
from reportlab.lib.styles import *
from reportlab.rl_config import *
from reportlab.lib.units import *
import reportlab.platypus.para as para1
import reportlab.platypus.paragraph as para2
import os
styles = getSampleStyleSheet()
text1 = """Test TrueType, <font face="Luxi">Test LUXI,</font> Test End"""
text2 = """Test PostScript, <font face="LettErrorRobot-Chrome">Test LUXI,</font> Test End"""
import reportlab.rl_config
reportlab.rl_config.warnOnMissingFontGlyphs = 0
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
def test():
# TrueType Font
pdfmetrics.registerFont(TTFont('Luxi', 'veramono.ttf'))
# PostScript Font
afmFile = 'LeERC___.AFM'
pfbFile = 'LeERC___.PFB'
justFace = pdfmetrics.EmbeddedType1Face(afmFile, pfbFile)
faceName = 'LettErrorRobot-Chrome'
pdfmetrics.registerTypeFace(justFace)
justFont = pdfmetrics.Font('LettErrorRobot-Chrome',
faceName,
'WinAnsiEncoding')
pdfmetrics.registerFont(justFont)
# Document
doc = SimpleDocTemplate("test.pdf")
story = []
story.append(para1.Paragraph(text1, styles["Normal"]))
story.append(para2.Paragraph(text1, styles["Normal"]))
story.append(para1.Paragraph(text2, styles["Normal"]))
story.append(para2.Paragraph(text2, styles["Normal"]))
doc.build(story)
if __name__=="__main__":
test()
os.system("start test.pdf")
More information about the reportlab-users
mailing list