RTL desktop and BiDi issues in KDE4

Robert Knight robertknight at gmail.com
Fri Jan 25 18:57:51 GMT 2008


> This application uses QGraphicsTextItem and I have not
> found a way to set the direction of the text

You could change the defaultTextOption property of the
QGraphicsTextItem's document so a QTextOption with the appropriate
text direction.

eg.

QTextOption option = graphicsTextItem->document();
option.setTextDirection( <appropriate text direction> );
graphicsTextItem->document()->setDefaultTextOption(option);

>From the docs, it seems that this needs to be done before the document
is filled.  Alternatively you can change the textCursor() property of
the QGraphicsTextItem.

QTextCursor cursor = graphicsTextItem->textCursor();
QTextCharFormat format = cursor.charFormat();
format.setLayoutDirection( <appropriate text direction > );
cursor.setFormat(format);
graphicsTextItem->setTextCursor(cursor);

Regards,
Robert.


On 25/01/2008, Diego Iastrubni <elcuco at kde.org> wrote:
> Hi all,
>
> I am seeing too much problems in KDE4 regarding BiDi/RTL. It seems that many
> applications are using self made widgets, which display text  with the wrong
> textLayoutDirection.
>
> I am having problems fixing those issues, and I am missing something, so I ask
> for your help. I hope that someone can help me, and I hope we all learn
> something new, and stop messing applications for Hebrew/Arabic/Farsi
> speakers :)
>
> Some examples:
>
> http://bugs.kde.org/show_bug.cgi?id=128268
> This is Hebrew lectures loading in ktouth. This issue is almost fixed, but I
> found a small problem. This application uses QGraphicsTextItem and I have not
> found a way to set the direction of the text. The actual direction is taken
> from the QPainter, which in turn is taken from the QWidget. This may lead to
> Hebrew text in LTR mode when loading Hebrew lectures under English UI, or
> English in RTL mode when loading English lectures in Hebrew UI (the problem
> is the location of the text cursor when typing "space", it will be on the
> wrong side).
>
> http://bugs.kde.org/show_bug.cgi?id=156654
> This is konsole, which is completely unusable for me. The lines there are
> rendered with direction=RTL, which is bad. After playing a while with the
> konsole code, I have no idea how to fix it. Setting the direction of
> TerminalDisplay did not help, and setting the layoutDirection on the QPainter
> on the paintEvent() did not help.
>
> http://bugs.kde.org/show_bug.cgi?id=156093
> This is kate, which is supposed to support BiDi, but currently just messes up
> things. I am working with Hamish Rodda to fix this. The problem is short is:
> each line should have it's own QTextCharFormat, which should contain a
> direction which is not "derived" from the widgets direction (lets ignore for
> the moment the issue that setting the direction to RTL should also align the
> line to the right).
>
> I am posing this in this list, since I assume (almost) every application in
> KDE has some issue related to RTL/BiDi, and sometimes, it's plainly easy to
> test this: just run your application with the switch "--reverse".
>
> I also would like the help of you, in fixing the first 2 items. I am getting
> help from Hamish about kate.
>
> Thanks!
>




More information about the kde-core-devel mailing list