summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2019-01-08 09:34:24 +0100
committerLiang Qi <liang.qi@qt.io>2019-01-08 09:34:24 +0100
commit0e96b5fe482802935ae202e2297404845e440d71 (patch)
tree79c566f18bc605261f69d750d2935b91edba3861 /src/gui/text
parentda43362921a62ea3163a042be20ec0f550d05cfa (diff)
parent5733dfbd90fd059e7310786faefb022b00289592 (diff)
Merge remote-tracking branch 'origin/5.12' into 5.12.1
Conflicts: src/widgets/kernel/qtooltip.cpp Change-Id: Ic2f9a425359050eb56b3a4e5162cf5e3447058c8
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qharfbuzzng.cpp2
-rw-r--r--src/gui/text/qtextengine.cpp10
-rw-r--r--src/gui/text/qtextlayout.cpp4
3 files changed, 16 insertions, 0 deletions
diff --git a/src/gui/text/qharfbuzzng.cpp b/src/gui/text/qharfbuzzng.cpp
index 21f880e7be..2f25aea92b 100644
--- a/src/gui/text/qharfbuzzng.cpp
+++ b/src/gui/text/qharfbuzzng.cpp
@@ -689,6 +689,8 @@ _hb_qt_font_create(QFontEngine *fe)
hb_font_set_scale(font, QFixed(x_ppem).value(), -QFixed(y_ppem).value());
hb_font_set_ppem(font, x_ppem, y_ppem);
+ hb_font_set_ptem(font, fe->fontDef.pointSize);
+
return font;
}
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 8de16038ad..bdb5592e9e 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -3192,6 +3192,16 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int
QChar ellipsisChar(0x2026);
+ // We only want to use the ellipsis character if it is from the main
+ // font (not one of the fallbacks), since using a fallback font
+ // will affect the metrics of the text, potentially causing it to shift
+ // when it is being elided.
+ if (engine->type() == QFontEngine::Multi) {
+ QFontEngineMulti *multiEngine = static_cast<QFontEngineMulti *>(engine);
+ multiEngine->ensureEngineAt(0);
+ engine = multiEngine->engine(0);
+ }
+
glyph_t glyph = engine->glyphIndex(ellipsisChar.unicode());
QGlyphLayout glyphs;
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index be306ed224..f3f0caa379 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -2598,6 +2598,7 @@ void QTextLine::draw(QPainter *p, const QPointF &pos, const QTextLayout::FormatR
Qt::IntersectClip);
else
x /= 2; // Centered
+ p->setFont(f);
p->drawText(QPointF(iterator.x.toReal() + x,
y.toReal()), visualTab);
}
@@ -2671,8 +2672,11 @@ void QTextLine::draw(QPainter *p, const QPointF &pos, const QTextLayout::FormatR
if (c.style() != Qt::NoBrush)
p->setPen(c.color());
QChar visualSpace(si.analysis.flags == QScriptAnalysis::Space ? (ushort)0xb7 : (ushort)0xb0);
+ QFont oldFont = p->font();
+ p->setFont(eng->font(si));
p->drawText(QPointF(iterator.x.toReal(), itemBaseLine.toReal()), visualSpace);
p->setPen(pen);
+ p->setFont(oldFont);
}
}
eng->drawDecorations(p);