[reportlab-users] Re: Using UTF-8 strings with ReportLab.

Matthew Somerville matthew at mysociety.org
Tue Dec 20 19:41:05 EST 2005

Jorge Godoy wrote:
> Could you help me to get there with such a setup?  What are the fonts you're
> using?

Transport and Rockwell are our default fonts. I just followed the 
instructions, something like (various lines from the code):

pdfmetrics.registerFont(ttfonts.TTFont('Transport', font_dir + 
p_head = ParagraphStyle('normal', alignment = TA_LEFT, spaceBefore = 0, 
spaceAfter = 0, fontSize = small_writing, leading = small_writing * 1.2, 
fontName = 'Transport')
c = canvas.Canvas(filename, pagesize=...)
story = [
   Paragraph('Some text'.encode('utf-8'), p_head)
f = Frame(x1, y1, w, h, ...)
f.addFromList(story, c)

You have to adapt the RegisterFont function if you want bold and italic in 
TTFs (see May 2004 archive).


More information about the reportlab-users mailing list