[reportlab-users] RTL Support

Muayyad AlSadi alsadi at gmail.com
Sun Apr 4 16:51:24 EDT 2010



> I have done it before on a Arabic scripts only, but I think I could improve it to support the

Unicode standard.

pyfribidi does that.

the problem now with the following issues:
1. setting the main direction to RTL not just align to right
2. align to right by default (it seems we have a problem with this)
3. problem with justified text

you may get patched report lab and pyfribdi2

http://www.ojuba.org/downloads/updates/3/i386/python-reportlab-2.3-3.oj3.i586.rpm
http://www.ojuba.org/downloads/updates/3/i386/pyfribidi-0.8.0-1.oj3.i586.rpm

I test it with this (and text is shaped correctly but it not aligned
to right correctly )
http://www.blog.pythonlibrary.org/2010/03/08/a-simple-step-by-step-reportlab-tutorial/



with the following modification

# -*- coding: UTF-8 -*-
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
pdfmetrics.registerFont(TTFont('Times-Roman',
'/usr/share/fonts/dejavu/DejaVuSans.ttf'))

styles.add(ParagraphStyle(name='Right', alignment=TA_RIGHT))

....
ptext="<font size=12>%s</font>" % " ".join([(u"%d. كلام كثير الجمال.
الخط العربي جميل" % i) for i in range(99)])
Story.append(Paragraph(ptext, styles["Right"]))


More information about the reportlab-users mailing list