Searching for UTF8 capable font for REPORTLAB

Marijan Tadin mtadin66 at yahoo.com
Mon Jan 19 05:45:48 CET 2004


Try following code, replace value of my_location_of_TTF with your
location of TTF (of course you should have TT fonts somewhere on your
machine, on windows they are allways there, AFAIK you can download them
for linux):

There is also mailing list on ReportLabs website, it is where I found
the hint how to use ReportLab and Unicode.


from reportlab.pdfgen import canvas
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont

canv = canvas.Canvas('test_03.pdf')
fontname = 'CS'

my_location_of_TTF = 'C:\WINNT\FONTS\comic.TTF'

pdfmetrics.registerFont(TTFont(fontname,my_location_of_TTF))
a=u'\u010d\u0107\u017e\u0161\u0111\u010c\u0106\u017d\u0160\u0110'
canv.setFont(fontname,10)
canv.drawString(50,100,'Some text:'+a.encode('UTF8'))
canv.save()


"Andreas Jung" <lists at andreas-jung.com> wrote in message
news:mailman.429.1074256100.12720.python-list at python.org...
> Reportlab has some problems with creating PDFs from UTF8 encoded text.
For
> this reason
> they are using a truetype font rina.ttf which looks *very ugly*. Does
> anyone know of a
> suitable free available truetype font that works with UTF8?
>
> -aj
>
>




More information about the Python-list mailing list