[reportlab-users] pyfribidi / fribidi versions

Robin Becker robin at reportlab.com
Tue Oct 26 08:48:27 EDT 2010


On 26/10/2010 09:14, Hosam Aly wrote:

> 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)

>>


thanks



>

> 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.

........

OK thanks, this was useful. I tried your experimental patch with pyfribidi2 and
svn trunk and used the test from the rtl support branch. I see the wrong
parentheses as well. It seems that we do need the styling parameter to be acted
upon to make the text appear as in the original. The output is attached as
experiment.pdf.


On the other hand with HEAD rtl-support branch I'm getting no difference between
the test outputs with the fribidi 0.19.2 + pyfribidi and the pyfribidi2 version
I have on windows. That branch now contains all the latest trunk changes and
seems to me at least to get the parentheses right. The result is attached as
rtl-support.pdf.

If the parentheses are a guide then we do need to know whether the desired
outcome is for an LTR/RTL outcome in reportlab as is done in the rtl-support
branch. In addition it seems as though the modernized rtl branch is working OK
with either the older pyfribidi2 or the latest pyfribidi.
--
Robin Becker
-------------- next part --------------
A non-text attachment was scrubbed...
Name: experiment.pdf
Type: application/pdf
Size: 23957 bytes
Desc: not available
Url : <http://two.pairlist.net/pipermail/reportlab-users/attachments/20101026/e5c2b8a4/attachment-0002.pdf>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rtl-support.pdf
Type: application/pdf
Size: 23937 bytes
Desc: not available
Url : <http://two.pairlist.net/pipermail/reportlab-users/attachments/20101026/e5c2b8a4/attachment-0003.pdf>


More information about the reportlab-users mailing list