Re: Unicode text Direction Detection



Thanks Behdad.  

On 8/17/05, Behdad Esfahbod <behdad cs toronto edu> wrote:
On Wed, 17 Aug 2005, Gaurav Jain wrote:

Hi,

I have a Unicode text, and I need to detect its direction by some BiDi
algorithm (i.e., whether it is Left-to-right or Right-to-left).  For
example, I need to look for the first "strong" directional character
in the text, and find out its direction.  Is there a way I can do that
using some GTK/GLib APIs?  Something, perhaps, on the line of the
Windows API GetStringTypeW() perhaps?

Any help in this regard would be appreciated!

Hello,

We have one of the best bidi direction handling in GNOME, but for
the purpose of your application, we don't have the needed API
defined I'm afraid.  The logic is implemented in FriBidi.  It
does have the API to give you back the paragraph direction, but
it analyzes the test at the same time too.  In future versions of
FriBidi it would have the exact API to just do what you're asking
for.

I found the pango API called pango_unichar_direction() which I can
probably use to determine if a given unicode character is RTL or LTR. 
So from what I understand, I will probably need to write a small
implementation of myself until GTK comes up with the API.

In GNOME though, Pango uses an internal copy of FriBidi, which
means, you don't have access to that facility.  And Pango doesn't
export what you need AFAIK.  Then there's the text widget in Gtk+
too, don't know whether it exports the direction of individual
paragraph.  I really doubt it does.

Please file a bug report with the exact feature you want (is it
just a paragraph of text you have, or text in a text widget,
etc), we will look at the API addition.
OK, I will do that.


Thanks,
Gaurav

--behdad
http://behdad.org/

gaurav



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]