[reportlab-users] Arabic support

Robin Becker robin at reportlab.com
Tue Sep 1 08:10:37 EDT 2015


There is some support for RTL in trunk reportlab. In reportlab/rl_settings there 
is a variable called rtlSupport (defaults to 0). If set to 1 using one of the 
standard override methods then reportlab attempts to import the fribidi 
libraries eg in reportlab/pdfgen/textobject.py

from pyfribidi2 import log2vis, ON as DIR_ON, LTR as DIR_LTR, RTL as DIR_RTL

in the _formatText method we are doing this

	def _formatText(self, text):
		"Generates PDF text output operator(s)"
		if log2vis and self.direction in ('LTR','RTL'):
			# Use pyfribidi to write the text in the correct visual order.
			text = log2vis(text, directionsMap.get(self.direction.upper(),DIR_ON),clean=True)

if the libraries are not installed or cause an error on import you should get a 
warning. I have fixed a bug related to the above so some people are using it. 
This low level approach to using fribidi is clearly wrong. We should be doing it 
at the parsing level, but that is hard since fribidi doesn't seem to allow for 
annotated characters ie carrying the colour font boldness etc etc through a call 
to log2vis isn't possible.
-- 
Robin Becker
On 24/08/2015 21:18, Fran Boon wrote:
> On 24 August 2015 at 15:07, Fran Boon <francisboon at gmail.com> wrote:
>> Is there a branch of ReportLab with RTL support included that I can
>> test / contribute to?
>> Or should I add my own support to our ReportLab routines using Python-BiDi?
>
> I did the latter for now & it seems to work well enough for my needs :)
>
> https://github.com/flavour/eden/blob/master/modules/s3/s3codecs/pdf.py#L138
>
> Thanks,
> Fran.
.......




More information about the reportlab-users mailing list