diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2021-01-12 08:39:14 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-02-03 11:30:49 +0000 |
commit | 99d3a65cf373bd563710ff91d9922845befa47a2 (patch) | |
tree | 121256f8ee2834c3a4e3b4496ea984aefe1f50ba | |
parent | 426c8b851adc163c3db4dfd37f31ca1ed1bb2cdb (diff) | |
download | qtbase-99d3a65cf373bd563710ff91d9922845befa47a2.tar.gz |
Use design metrics when adding text to QPainterPath
When we add text to QPainterPath, we will add the design metrics
(unhinted glyphs) and scale these down to match the target font size.
But the glyph positions we pass in are based on the hinted metrics,
samples at the target font size. Thus, on fonts/systems with hinting,
these do not match the scaled design metrics outlines.
To fix this issue, we make sure the text layout uses design metrics
when determining the glyph positions.
[ChangeLog][QtGui][Text] Fixed an issue where QPainterPath::addText()
would get inconsistent kerning for smaller font sizes when hinting is
enabled.
Fixes: QTBUG-20900
Change-Id: I651997d1a6a86e6271557438afa2cdad078a83ca
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
(cherry picked from commit 6a3f8cbc3ad47d8585aac25d3775ed2350afe20c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/gui/painting/qpainterpath.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index e6945d1dcd..8f62216c22 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -1222,6 +1222,11 @@ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString & QTextLayout layout(text, f); layout.setCacheEnabled(true); + + QTextOption opt = layout.textOption(); + opt.setUseDesignMetrics(true); + layout.setTextOption(opt); + QTextEngine *eng = layout.engine(); layout.beginLayout(); QTextLine line = layout.createLine(); |