RTL text direction support

205 views
Skip to first unread message

Anupama M.Ramaswamy

unread,
Jan 20, 2012, 5:52:58 AM1/20/12
to Flying Saucer Users
I am using Flying Saucer for one of my projects and first of all my
kudos and thanks to the flying saucer team for a great product.
Recently I have been responsible for supporting Arabic in my
application and I have faced a few issues.

I followed this thread in this group
http://groups.google.com/group/flying-saucer-users/browse_thread/thread/9f409fb987e943a2.
That got me around to render the arabic text correctly,both direction
as well as ligatures.

But I would require the entire page to be filpped in the arabic mode.
My HTML contains tables and I would think the column positions should
be RTL for the page to be meaningful.

Here are a few thoughts. If someone will help me validate these
approaches and say whether it is worthwhile giving a try. I did not
want get to a wrong path and go too far before realizing it would not
work.

1) I can use a ReplacedElementFactory which can handle tables. Instead
of creating my own ReplacedElement, I would just change the positions
of the various coulmns within the BlockBox (TableBox) in this case and
delegate it back to the default ReplacedElementFactory. Here I am
expecting that the rendering will be normally processed and the Table
will be rendered alright.

2) Subclass the OutputDevice. This subclass will use an additional
transform when the language is arabic. Not sure if layout() will use
the transform for all elements. If it does, then the text drawing
could be adversly affected - simple transform will not work for BiDi
text ?

Tables is just an example, but I would want to do this every other
element in my HTML whose position on the page is affected by the
reading direction.

Thanks
Anupama

Peter Brant

unread,
Jan 26, 2012, 7:54:12 AM1/26/12
to flying-sa...@googlegroups.com
Yeah, the only way I can think of doing it correctly is by modifying
the layout code to pin things to the right instead of the left. This
probably wouldn't be *too* hard to implement actually. IIRC from the
KHTML source code, there were basically just some blocks like

if (direction == RTL) {
... do RTL arithmetic ...
} else {
... do LTR arithmetic ..
}

at a few strategic places in the code. I remember being surprised at
how few there were.

Pete

Reply all
Reply to author
Forward
0 new messages