From dc6191ccb4f03d33314981f71cd63e7aecabe8ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 23 Jun 2015 13:21:56 +0200 Subject: [PATCH] Treat color (ARGB) glyphs, e.g. Emoji, as having unreliable glyph outlines This is used by the scene graph to automatically switch over from distance field text to native text rendering for the given glyph node, which allows mixing regular text with Emoji in e.g. a Text item without having to set renderType to Text.NativeRendering. Change-Id: I5d96d1dab329a975e3442284bf4c5a82174177c9 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qfontengine.cpp | 10 +++++----- src/plugins/platforms/windows/qwindowsfontengine.cpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 87e6c30afe3..6f5d1786555 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -1344,13 +1344,13 @@ QByteArray QFontEngine::convertToPostscriptFontFamilyName(const QByteArray &fami return f; } -/** - * Some font engines like the windows font engine - * can not reliable create outline paths - */ +// Allow font engines (e.g. Windows) that can not reliably create +// outline paths for distance-field rendering to switch the scene +// graph over to native text rendering. bool QFontEngine::hasUnreliableGlyphOutline() const { - return false; + // Color glyphs (Emoji) are generally not suited for outlining + return glyphFormat == QFontEngine::Format_ARGB; } QFixed QFontEngine::lastRightBearing(const QGlyphLayout &glyphs, bool round) diff --git a/src/plugins/platforms/windows/qwindowsfontengine.cpp b/src/plugins/platforms/windows/qwindowsfontengine.cpp index ef2ad110ca8..16b9118e81d 100644 --- a/src/plugins/platforms/windows/qwindowsfontengine.cpp +++ b/src/plugins/platforms/windows/qwindowsfontengine.cpp @@ -671,7 +671,7 @@ void QWindowsFontEngine::getGlyphBearings(glyph_t glyph, qreal *leftBearing, qre bool QWindowsFontEngine::hasUnreliableGlyphOutline() const { - return hasUnreliableOutline; + return hasUnreliableOutline || QFontEngine::hasUnreliableGlyphOutline(); } qreal QWindowsFontEngine::minLeftBearing() const