summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDavid Faure <david.faure@kdab.com>2017-01-09 00:10:42 +0100
committerDavid Faure <david.faure@kdab.com>2017-01-11 15:15:39 +0000
commit2bb01172a76f14b1f57010b79207f6b9a9bf3f53 (patch)
treeff6e64b06e334f77951be90caf93c2ee94b26a90 /tests
parent62882ad2fe3d9f70c876d7a51a5aab4118ce1ba3 (diff)
QFont: fix fromString(toString()) when application font has styleName
The style name needs to be cleared if not present in the string, otherwise the style name from qApp->font() (which propagates to any default-constructed QFont) remains. Change-Id: I9b6522a39a38526cced8a11ed02ae32582026480 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Konstantin Shegunov <kshegunov@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/gui/text/qfont/tst_qfont.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/auto/gui/text/qfont/tst_qfont.cpp b/tests/auto/gui/text/qfont/tst_qfont.cpp
index 06c0ba0819..2603206ab0 100644
--- a/tests/auto/gui/text/qfont/tst_qfont.cpp
+++ b/tests/auto/gui/text/qfont/tst_qfont.cpp
@@ -63,6 +63,7 @@ private slots:
void defaultFamily_data();
void defaultFamily();
void toAndFromString();
+ void fromStringWithoutStyleName();
void sharing();
};
@@ -561,6 +562,19 @@ void tst_QFont::toAndFromString()
}
}
+void tst_QFont::fromStringWithoutStyleName()
+{
+ QFont font1;
+ font1.fromString("Noto Sans,12,-1,5,50,0,0,0,0,0,Regular");
+
+ QFont font2 = font1;
+ const QString str = "Times,16,-1,5,50,0,0,0,0,0";
+ font2.fromString(str);
+
+ QCOMPARE(font2.toString(), str);
+}
+
+
void tst_QFont::sharing()
{
// QFontCache references the engineData