Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Bi-Directional text widget
Forum Updated to NodeBB v4.3 + New Features

Bi-Directional text widget

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 2.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    soroush
    wrote on last edited by
    #1

    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 :-)

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • S Offline
        S Offline
        soroush
        wrote on last edited by
        #3

        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.

        S 1 Reply Last reply
        0
        • S soroush

          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.

          S Offline
          S Offline
          s_big_iron
          wrote on last edited by
          #4

          @soroush
          This issue will be fixed in 5.11.
          http://code.qt.io/cgit/qt/qtbase.git/commit/src/gui/text/qtextengine.cpp?h=dev&id=7f504283ef44c35dfca7198a80742063a940fabd
          https://bugreports.qt.io/browse/QTBUG-57743

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved