Bi-Directional text widget



  • Hi there

    I need a Text Editing widget with bi-directionality support. First want to know if such a widget is already written or not. If not I have to write myself.
    Bi-directionality: Due to "Unicode Annex #9":http://unicode.org/reports/tr9/ Bidirectional text environment should have a property (Direction) specifying way to render text. direction could be one of Right-To-Left or Left-To-Right. In Left to right mode, normal rendering algorithm will apply: all character shapes (obtained from font) are rendered in their local direction flag. In RTL mode, priority of rendering flag is RTL unless it declared in glyph as Strong LTR.

    In fact huge part of rendering mechanism is already implemented in current text rendering engines. I just need to add a few modifications to obtain a 2-step rendering algorithm that is equal to RTL mode. second step is this:
    If RTL mode is on, then treat every LTR character 'L' as 'L'+<RIGHT-TO-LEFT EMBEDDING> (U+202B) when rendering
    or this:
    If RTL mode is on, then treat every character 'C' as 'C'+<RIGHT-TO-LEFT EMBEDDING> (U+202B) when rendering

    Is it possible in Qt? I would like to subclass QTextEdit to add this feature... Please give me a starting point, hint, advice, code sample or any other idea.

    Thanks in advance :-)



  • Does QWidget::setLayoutDirection do what you need, or do I misunderstand your needs?



  • No, does not. It's related to direction of text (not widget layout).
    problem is with bi-direction characters like: < > { } ( ) ! : + - etc.
    For example, supposing R is an RTL character and L is an LTR one, this text:
    @LLL RR (R)@
    Will be displayed like this:
    @LLL R) RR)@
    wich is not true. if you put a RIGHT-TO-LEFT EMBEDDING MARK before first R, it will render correctly. Adding the direction flag provides a way to avoid inserting extra formatting characters to plain text.

    In popular WYSIWYG editors like MS Word, user can change paragraph direction in a natural manner. (Ctrl+Right Shift). This sould not be conflicted with text alignment.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.