diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com> | 2016-03-02 16:37:40 +0100 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com> | 2016-03-15 08:54:16 +0000 |
commit | 17d435fd8b2ed3a8ac6f93d17d0e78cd61bd7851 (patch) | |
tree | 545828632c0ed5bed996a338ee2291ee85b668a1 /tests/auto/quick/qquicktext/tst_qquicktext.cpp | |
parent | fe7c2cbab3a8967b7f19f2aae8f5152ab23bf43d (diff) |
Add property for setting hinting preference on fonts
As screen density is rapidly increasing and user interfaces are moving
more and more towards using unhinted text as default, we have to make
it possible to select the hint level from Qt Quick as well. While
this is already partially covered by the unhinted QtRendering render type,
it is still interesting to be able to tweak the native rendering accordingly,
since this is a more precise rasterization. QtRendering also doesn't support
medium hinting.
[ChangeLog][Text] Added "hintingPreference" property to Text, TextEdit and
TextInput.
Change-Id: Ib99dbea24aba082481629deddde88c04cdeb8cdb
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'tests/auto/quick/qquicktext/tst_qquicktext.cpp')
-rw-r--r-- | tests/auto/quick/qquicktext/tst_qquicktext.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp index d163ee785e..1cd3d1f9e2 100644 --- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp @@ -146,6 +146,8 @@ private slots: void padding(); + void hintingPreference(); + private: QStringList standard; QStringList richText; @@ -4152,6 +4154,33 @@ void tst_qquicktext::padding() delete root; } +void tst_qquicktext::hintingPreference() +{ + { + QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE((int)textObject->font().hintingPreference(), (int)QFont::PreferDefaultHinting); + + delete textObject; + } + { + QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.hintingPreference: Font.PreferNoHinting }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE((int)textObject->font().hintingPreference(), (int)QFont::PreferNoHinting); + + delete textObject; + } +} + + QTEST_MAIN(tst_qquicktext) #include "tst_qquicktext.moc" |