aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquicktext.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2020-08-12 09:27:03 +0200
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2020-08-17 07:09:31 +0200
commitcbbbfe3bff29d8db84771e07ac6f16209b0969d1 (patch)
treea37c1a23cadc6ae6a0d8e367d0b582768e943e6a /src/quick/items/qquicktext.cpp
parent0cb02b7ee0f72674640ffe5a0fabc1dacc259de0 (diff)
Add renderTypeQuality property to Text element
For large scale text, the default distance field size gives artifacts on certain font features. We already have an environment variable which overrides this on an application level, but this will cause all distance fields to be rendered at the high resolution, whereas you may just want it for one particular text field. Since this becomes an especially important use case now that we can embed the text fields in a 3D scene, we add a property which can be used to tweak the base font size used for generating the distance fields. [ChangeLog][QtQuick][Text] Added "renderTypeQuality" property, which can be used in cases of very large fonts, where Qt's font rasterization may show some rendering artifacts when using the default quality. Fixes: QTBUG-84696 Change-Id: Ie4205e82cf441562dcc65a8e432a941a3baeddf3 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/quick/items/qquicktext.cpp')
-rw-r--r--src/quick/items/qquicktext.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp
index 79665a3cda..b198c5f114 100644
--- a/src/quick/items/qquicktext.cpp
+++ b/src/quick/items/qquicktext.cpp
@@ -112,6 +112,7 @@ QQuickTextPrivate::ExtraData::ExtraData()
, minimumPointSize(12)
, nbActiveDownloads(0)
, maximumLineCount(INT_MAX)
+ , renderTypeQuality(QQuickText::DefaultRenderTypeQuality)
, lineHeightValid(false)
, lineHeightMode(QQuickText::ProportionalHeight)
, fontSizeMode(QQuickText::FixedSize)
@@ -2476,6 +2477,7 @@ QSGNode *QQuickText::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data
node = static_cast<QQuickTextNode *>(oldNode);
node->setUseNativeRenderer(d->renderType == NativeRendering);
+ node->setRenderTypeQuality(d->renderTypeQuality());
node->deleteContent();
node->setMatrix(QMatrix4x4());
@@ -2934,6 +2936,50 @@ void QQuickText::hoverLeaveEvent(QHoverEvent *event)
}
/*!
+ \qmlproperty int QtQuick::Text::renderTypeQuality
+
+ Override the default rendering type quality for this component. This is a low-level
+ customization which can be ignored in most cases. It currently only has an effect
+ when \l renderType is \c Text.QtRendering.
+
+ The rasterization algorithm used by Text.QtRendering may give artifacts at
+ large text sizes, such as sharp corners looking rounder than they should. If
+ this is an issue for specific text items, increase the \c renderTypeQuality to
+ improve rendering quality, at the expense of memory consumption.
+
+ The \c renderTypeQuality may be any integer over 0, or one of the following
+ predefined values
+
+ \list
+ \li Text.DefaultRenderTypeQuality (default) = -1
+ \li Text.LowRenderTypeQuality = 26
+ \li Text.NormalRenderTypeQuality = 52
+ \li Text.HighRenderTypeQuality = 104
+ \li Text.VeryHighRenderTypeQuality = 208
+ \endlist
+*/
+int QQuickText::renderTypeQuality() const
+{
+ Q_D(const QQuickText);
+ return d->renderTypeQuality();
+}
+
+void QQuickText::setRenderTypeQuality(int renderTypeQuality)
+{
+ Q_D(QQuickText);
+ if (renderTypeQuality == d->renderTypeQuality())
+ return;
+ d->extra.value().renderTypeQuality = renderTypeQuality;
+
+ if (isComponentComplete()) {
+ d->updateType = QQuickTextPrivate::UpdatePaintNode;
+ update();
+ }
+
+ emit renderTypeQualityChanged();
+}
+
+/*!
\qmlproperty enumeration QtQuick::Text::renderType
Override the default rendering type for this component.