summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2020-11-18 13:45:19 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2020-11-21 03:20:56 +0000
commit2acf1122eaf0ec4a3bd06fb0c199374a4fe1c66d (patch)
treec33968560185e79e55e2070e7211315985997234 /src/gui
parentc0b0ade6223c7ed492069f2fe0d801b4a5893e3d (diff)
Fix weight when reading old serialized QFonts
The QFont::fromString() needs to differ between strings produced before and after Qt 6.0 when interpreting the weight value, since in older strings this will be the legacy scale. Luckily the number of tokens in the string can be used for this purpose, since many tokens were added in Qt 6.0. This broke KDE, where font settings are stored in QSettings and serialized using QFont::toString() from Qt 5. Fixes: QTBUG-88589 Change-Id: I199737fed61917f8b9d8f86176ead29a89eb8e0c Reviewed-by: Andy Shaw <andy.shaw@qt.io> (cherry picked from commit 1d14067680f02f47b2f8ff375c44eb64633eec02) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/text/qfont.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index 53344418a0..63b13df38b 100644
--- a/src/gui/text/qfont.cpp
+++ b/src/gui/text/qfont.cpp
@@ -2150,7 +2150,10 @@ bool QFont::fromString(const QString &descrip)
if (l[2].toInt() > 0)
setPixelSize(l[2].toInt());
setStyleHint((StyleHint) l[3].toInt());
- setWeight(QFont::Weight(l[4].toInt()));
+ if (count >= 16)
+ setWeight(QFont::Weight(l[4].toInt()));
+ else
+ setWeight(QFont::Weight(qt_legacyToOpenTypeWeight(l[4].toInt())));
setStyle((QFont::Style)l[5].toInt());
setUnderline(l[6].toInt());
setStrikeOut(l[7].toInt());