aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/qsgdefaultglyphnode.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2020-06-16 09:03:43 +0200
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2020-06-18 07:13:48 +0200
commite8d9bc1bcada7d94af5a33d64a9afc860ede5b84 (patch)
tree46dab1024bab3e91239be6adfceac7719b4d70e4 /src/quick/scenegraph/qsgdefaultglyphnode.cpp
parent286cb9d4021f46e51162b30c4336fe52555f1756 (diff)
Fix outline for connected text
For any font where glyphs are connected (any font could have this, but specifically Arabic and Indic fonts will typically always connect glyphs, as it is required to express the language correctly), we would draw the outline on a per-glyph basis, thus getting outlines that disconnect the glyphs. In order to fix this, we have to draw the fill of the glyphs in a separate pass after the outline has been drawn. Note that in order for this to look correct, we have to disable subpixel antialiasing on the fill, which required some plumbing in the native rendering glyph node. The outline shaders have also been changed to only draw the outline and not the fill. [ChangeLog][QtQuick][Text] Fixed Outline style on connected glyphs, especially visible in e.g. Arabic and Indic writing systems. Pick-to: 5.15 Fixes: QTBUG-69301 Fixes: QTBUG-83358 Change-Id: If52a940bfb0267384ea002120655aed1310458a1 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/quick/scenegraph/qsgdefaultglyphnode.cpp')
-rw-r--r--src/quick/scenegraph/qsgdefaultglyphnode.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/quick/scenegraph/qsgdefaultglyphnode.cpp b/src/quick/scenegraph/qsgdefaultglyphnode.cpp
index 5bd5cc4891..d3e0d5a7c5 100644
--- a/src/quick/scenegraph/qsgdefaultglyphnode.cpp
+++ b/src/quick/scenegraph/qsgdefaultglyphnode.cpp
@@ -40,12 +40,15 @@
#include "qsgdefaultglyphnode_p.h"
#include "qsgdefaultglyphnode_p_p.h"
+#include <private/qrawfont_p.h>
+
QT_BEGIN_NAMESPACE
QSGDefaultGlyphNode::QSGDefaultGlyphNode(QSGRenderContext *context)
: m_context(context)
, m_glyphNodeType(RootGlyphNode)
, m_dirtyGeometry(false)
+ , m_preferredAntialiasingMode(DefaultAntialiasing)
{
setFlag(UsePreprocess);
}
@@ -59,6 +62,11 @@ QSGDefaultGlyphNode::~QSGDefaultGlyphNode()
m_nodesToDelete.clear();
}
+void QSGDefaultGlyphNode::setPreferredAntialiasingMode(AntialiasingMode mode)
+{
+ m_preferredAntialiasingMode = mode;
+}
+
void QSGDefaultGlyphNode::setMaterialColor(const QColor &color)
{
static_cast<QSGTextMaskMaterial *>(m_material)->setColor(color);
@@ -76,7 +84,27 @@ void QSGDefaultGlyphNode::update()
QMargins margins(0, 0, 0, 0);
if (m_style == QQuickText::Normal) {
- m_material = new QSGTextMaskMaterial(m_context, QVector4D(m_color.redF(), m_color.greenF(), m_color.blueF(), m_color.alphaF()), font);
+ QFontEngine::GlyphFormat glyphFormat;
+
+ // Don't try to override glyph format of color fonts
+ if (QRawFontPrivate::get(font)->fontEngine->glyphFormat == QFontEngine::Format_ARGB) {
+ glyphFormat = QFontEngine::Format_None;
+ } else {
+ switch (m_preferredAntialiasingMode) {
+ case GrayAntialiasing:
+ glyphFormat = QFontEngine::Format_A8;
+ break;
+ case HighQualitySubPixelAntialiasing:
+ case LowQualitySubPixelAntialiasing:
+ glyphFormat = QFontEngine::Format_A32;
+ break;
+ default:
+ glyphFormat = QFontEngine::Format_None;
+ break;
+ }
+ }
+
+ m_material = new QSGTextMaskMaterial(m_context, QVector4D(m_color.redF(), m_color.greenF(), m_color.blueF(), m_color.alphaF()), font, glyphFormat);
} else if (m_style == QQuickText::Outline) {
QSGOutlinedTextMaterial *material = new QSGOutlinedTextMaterial(m_context, font);
material->setStyleColor(m_styleColor);