Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-9078

QTextLayout does not account for bearing correctly in RTL or bidi text

    XMLWordPrintable

Details

    Description

      Since Qt 4.6.0, there has been logic in QTextLayout which accounts for a negative right bearing when finding breaks in the text. This only makes sense for LTR text, as in bidi or RTL text, the logically last glyph of a string may be the visually left-most glyph, and thus the relevant metric is the left bearing and not the right. To support this correctly, the algorithm needs to be rewritten to account for the visual layout of the glyphs.

      In pseudo-code:

      newLineWidth = currentLineWidth + advance(currentGlyph);
      
      if (isPossibleBreakPoint) {
        if (newLineWidth > availableLineWidth) {
          doVisualLayout();
          leftMostGlyph = findLeftMostGlyph();
          rightMostGlyph = findRightMostGlyph();
          if (currentLineWidth - leftBearing(leftMostGlyph) - rightBearing(rightMostGlyph) > availableLineWidth) 
            breakPoint = lastPossibleBreakPoint;
        } else {
          lastPossibleBreakPoint = currentPosition;
        }
      }
      

      This should make both RTL and bidi text correctly account for the bearing when laying out the text.

      In addition, the original change had the extra expected effect that the bearing would be accounted for in QFontMetrics::boundingRect(). We need to make sure this still works, and also includes the left bearing.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            esabraha Eskil Abrahamsen Blomfeldt
            Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes