Hi.
Thanks for your response and your welcome ;-). If someone uses
QPainter::drawText for a complete text, it works, but when words are
drawn separately, all the things should be controlled manually.
lines 284-286 from src/frontends/qt3/QLPainter.C
--
               // We need to draw the text as LTR as we use our own bidi
               // code.
               qp_->drawText(x, y, str, -1, QPainter::LTR);
--
There's a QPainter::Auto that can be used instead of QPainter::LTR. I
tested this, but the problem is with the words. You can see the result
attached. The words are in wrong order, and they are written starting
from the left side of the screen.
Not only characters should be written from right to left, but the
whole Arabic part should be written from right to left. I mean the
words should be written in reverse order; There are also
considerations about the context, that can be right-to-left or
left-to-right. Someone can try gedit to understand what should
actually shown on screen, because gedit is known to be perfect in
bilingual text.
These are results from applying bidirectional algorithm on a sample
text. Suppose upper case words are Arabic.
---
   ./test_fribidi -capital_rtl tests/test-capital-rtl
car is THE CAR in arabic            => car is RAC EHT in arabic
CAR IS the car IN ENGLISH           =>           HSILGNE NI the car SI RAC
he said "IT IS 123, 456, OK"        => he said "KO ,456 ,123 SI TI"
he said "IT IS (123, 456), OK"      => he said "KO ,(456 ,123) SI TI"
he said "IT IS 123,456, OK"         => he said "KO ,123,456 SI TI"
he said "IT IS (123,456), OK"       => he said "KO ,(123,456) SI TI"
HE SAID "it is 123, 456, ok"        =>        "it is 123, 456, ok" DIAS EH
<H123>shalom</H123>                 =>                 <123H/>shalom<123H>
<h123>SAALAM</h123>                 => <h123>MALAAS</h123>
HE SAID "it is a car!" AND RAN      =>      NAR DNA "!it is a car" DIAS EH
HE SAID "it is a car!x" AND RAN     =>     NAR DNA "it is a car!x" DIAS EH
-2 CELSIUS IS COLD                  =>                  DLOC SI SUISLEC -2
SOLVE 1*5 1-5 1/5 1+5               =>               1+5 1/5 1-5 5*1 EVLOS
THE RANGE IS 2.5..5                 =>                 5..2.5 SI EGNAR EHT
---
For example, THE CAR is changed to "RAC EHT" when shown between
English characters. See that lines like ``HE SAID "it is a car!x" AND
RAN'' is written from right to left(starting from the right part of
the screen) and lines like the mentioned one, are written from left to
right(starting from the left part of the screen).
I talked of libfribidi, because it's possible to do this with that
library. Because it's low level, it can do the things like converting
logical representation of text into visual representation of it.
Please look at this page:
http://imagic.weizmann.ac.il/~dov/freesw/FriBidi/
I quote some useful parts from it:
--
The reordering of characters is done through the function:

    void
    fribidi_log2vis(/* input */
                    FriBidiChar *str,
                    int len,
                    FriBidiCharType *pbase_dir,
                    /* output */
                    FriBidiChar *visual_str,
                    gint        *position_L_to_V_list,
                    gint        *position_V_to_L_list,
                    gint8       *embedding_level_list
                    )

where

   str         is the Unicode input string
   len         is the length of the Unicode string
   pbase_dir   is the input and output base direction. If base ==
FRIBIDI_TYPE_N then fribidi_log2vis calculates the base direction on
its own according to the BiDi algorithm.
   visual_str  The reordered output Unicode string.
   position_L_to_V_list        Maps the positions in the logical string to
positions in the visual string.
   position_V_to_L_list        Maps the positions in the visual string to
the positions in the logical string.
   embedding_level_list        Returns the classification of each
character. Even levels indicate LTR characters, and odd levels
indicate RTL characters. The main use of this list is in interactive
applications when the embedding e.g. level determines cursor display.
--
Thanks.

<<attachment: word-bidi.jpg>>

Reply via email to