Details
-
Bug
-
Resolution: Out of scope
-
P2: Important
-
4.6.0
-
None
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.