summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTang Haixiang <tanghaixiang@uniontech.com>2021-04-07 16:46:58 +0800
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-04-20 10:15:45 +0000
commit9b0ffccabd0bf668b052b0ce74980cc3a0b859e5 (patch)
tree53e6fa82409393dcbdd55712d4a5255eae57d8e5
parentff9a091241370c266064c1585e56f4fb5d2436c8 (diff)
Draw the cursor considering the descent is 0
When the descent of the item is 0, ascent is the height of the item, base(base = si.ascent)> sl.base. At this time, sl.descent is not considered. The calculated y value may be <0. Fixes: QTBUG-86823 Fixes: QTBUG-92468 Change-Id: I9cf088dec9162595e52ff72aa90ec3153a30fb72 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit e99a883bd382ca950192bd66cafb2a1de6394ce7) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/gui/text/qtextlayout.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index b2b87fb92e..c1a27b2556 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -1299,13 +1299,13 @@ void QTextLayout::drawCursor(QPainter *p, const QPointF &pos, int cursorPosition
bool rightToLeft = d->isRightToLeft();
if (itm >= 0) {
const QScriptItem &si = d->layoutData->items.at(itm);
- if (si.ascent > 0)
+ if (si.ascent >= 0)
base = si.ascent;
- if (si.descent > 0)
+ if (si.descent >= 0)
descent = si.descent;
rightToLeft = si.analysis.bidiLevel % 2;
}
- qreal y = position.y() + (sl.y + sl.base() - base).toReal();
+ qreal y = position.y() + (sl.y + sl.base() + sl.descent - base - descent).toReal();
bool toggleAntialiasing = !(p->renderHints() & QPainter::Antialiasing)
&& (p->transform().type() > QTransform::TxTranslate);
if (toggleAntialiasing)