Menu

#3 RTL rendering?

open
nobody
None
5
2008-07-25
2008-07-25
Lars Huttar
No

Hello,
I got the FTGL demos running on Windows, and they are fun! Impressive stuff. Especially the Russian and Chinese.

For the project I'm doing I want to use Hebrew.
When I plugged Hebrew into your demos, though, they choked (see attached screenshot, and compare to http://www.biblegateway.com/passage/?search=Gen.%201:1-3&version=81\).
The issues are:
(1) characters are laid out left-to-right although the script is RTL;
(2) non-spacing characters, such as diacritics and cantillation marks, are spaced just like other characters, instead of being placed over the previous character.

I don't know how big of a can of worms it would be to support RTL rendering. I know you can get into very deep issues with full Hebrew and Arabic support; that's probably beyond the scope of FTGL, and into something more like Pango.

But I'm wondering if FTGL can at least fix the above two issues, purely using information found in the font itself (i.e. not having to look up information in the Unicode database, for example).

Discussion

  • Lars Huttar

    Lars Huttar - 2008-07-25

    screenshot of FTGLMFontDemo with Hebrew

     
  • Lars Huttar

    Lars Huttar - 2008-07-25

    Logged In: YES
    user_id=294943
    Originator: YES

    OK, regarding (1), I got this far: for the RTL layout, the trick is to decrement the pen position by the "advance" of each RTL glyph, instead of incrementing the pen position.
    (http://freetype.sourceforge.net/freetype2/docs/glyphs/glyphs-5.html#section-4)
    This would be in a method like FTSimpleLayoutImpl::WrapTextI().

    The gotcha is, how do you know which glyphs are RTL? In Hebrew, letters are RTL and numbers are LTR. I'm told that you have to look up this info in the Unicode character properties database. E.g. by using the ICU library. That sounds like something beyond the scope of FTGL.

    I haven't looked into (2) as much, but it sounds more doable: "an overstriking glyph will have an advance width of 0 with possibly a negative left side bearing (if it is intended to follow the overstruck glyph)" (http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&item_id=IWS-Chapter08). Sounds like it should work automatically based on glyph advance and bearing info in the font. But I guess it doesn't currently.

    Anyway, since RTL layout is a requirement for me, I'm going to proceed by trying to develop with pango (and possibly gtk+).
    The drawback there is that it sounds hard to link with in Windows.
    Best of success to you.

    Lars

     

Log in to post a comment.