[reportlab-users] pyfribidi / fribidi versions

Hosam Aly haly at centrivision.com
Tue Oct 26 04:14:29 EDT 2010


Hello,

Using Ubuntu 10.10, ReportLab 2.4-3, libfribidi0 0.19.2-1 and
python-pyfribidi 0.10.0-2 (all from the default Ubuntu partner
repositories), I have been successful at generating RTL text using
ReportLab, by doing a very minor change. In the file `pdfgen/textobject.py',
add the following at the top:

try:

> import pyfribidi

> shapeRTL = lambda text: pyfribidi.log2vis(text, pyfribidi.ON)

> except:

> from warnings import warn

> warn('pyfribidi is not installed. RTL text is not supported.')

> shapeRTL = lambda text: text

>


And the following line at the very beginning of the method
'_formatText(self, text)':


> text = shapeRTL(text)

>


This seems to be the simplest way of supporting RTL currently, without
affecting any of ReportLab's APIs. The other changes I had done in the
RTL-support branch were to support exposing the RTL property to users, but
they need to be reviewed before being merged.

That said, testing the change above using the 'test_bidi' method in
'tests/test_paragraph.py' on the RTL-support branch yields correct results
in most cases, but it fails to produce correct output in a few cases. I
don't know whether this may be caused by changes between ReportLab 2.3 and
2.4. However, it's easy to spot the difference (even if you can't read the
text) by comparing the generated PDF with the output of calling 'print
pyfribidi.log2vis(text, pyfribidi.ON)' on the tested text directly from a
terminal. For example, there is an error with the parenthesis in one case.

I'm sorry for my late reply, but I'm too busy nowadays. If you need any more
help, please don't hesitate to contact me.


Best regards,

Hosam Aly
Software Engineer
+20 (11) 8000-789
http://www.linkedin.com/in/hosamaly
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20101026/f1426598/attachment.htm>


More information about the reportlab-users mailing list