From 2e3439dc945cc5e0f19c014030ae6a0d8b93f2a7 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 26 Nov 2024 10:47:30 +0100 Subject: [PATCH] Don't support subpixel positioning for color fonts This comes at a price and it does not really make sense for emojis. Change-Id: I57148bff48a48bb81a03203626df25646c9acb6a Reviewed-by: Eirik Aavitsland (cherry picked from commit fd9c9788f73cb088229701dd92443aa04005a4a3) Reviewed-by: Qt Cherry-pick Bot --- src/gui/text/coretext/qfontengine_coretext_p.h | 2 +- src/gui/text/freetype/qfontengine_ft_p.h | 5 +++-- src/gui/text/windows/qwindowsfontenginedirectwrite.cpp | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gui/text/coretext/qfontengine_coretext_p.h b/src/gui/text/coretext/qfontengine_coretext_p.h index 2f388c32bcf..d24707cd0dc 100644 --- a/src/gui/text/coretext/qfontengine_coretext_p.h +++ b/src/gui/text/coretext/qfontengine_coretext_p.h @@ -54,7 +54,7 @@ public: bool canRender(const QChar *string, int len) const override; int synthesized() const override { return synthesisFlags; } - bool supportsHorizontalSubPixelPositions() const override { return true; } + bool supportsHorizontalSubPixelPositions() const override { return !isColorFont(); } bool supportsVerticalSubPixelPositions() const override { return false; } QFixed lineThickness() const override; diff --git a/src/gui/text/freetype/qfontengine_ft_p.h b/src/gui/text/freetype/qfontengine_ft_p.h index ec4164bfd82..b73b7261be6 100644 --- a/src/gui/text/freetype/qfontengine_ft_p.h +++ b/src/gui/text/freetype/qfontengine_ft_p.h @@ -152,8 +152,9 @@ private: QFixed emSquareSize() const override; bool supportsHorizontalSubPixelPositions() const override { - return default_hint_style == HintLight || - default_hint_style == HintNone; + return !isColorFont() + && (default_hint_style == HintLight || + default_hint_style == HintNone); } bool supportsVerticalSubPixelPositions() const override diff --git a/src/gui/text/windows/qwindowsfontenginedirectwrite.cpp b/src/gui/text/windows/qwindowsfontenginedirectwrite.cpp index 4f73633667a..764c2854f43 100644 --- a/src/gui/text/windows/qwindowsfontenginedirectwrite.cpp +++ b/src/gui/text/windows/qwindowsfontenginedirectwrite.cpp @@ -688,7 +688,8 @@ QImage QWindowsFontEngineDirectWrite::alphaMapForGlyph(glyph_t glyph, bool QWindowsFontEngineDirectWrite::supportsHorizontalSubPixelPositions() const { DWRITE_RENDERING_MODE renderMode = hintingPreferenceToRenderingMode(fontDef); - return (renderMode != DWRITE_RENDERING_MODE_GDI_CLASSIC + return (!isColorFont() + && renderMode != DWRITE_RENDERING_MODE_GDI_CLASSIC && renderMode != DWRITE_RENDERING_MODE_GDI_NATURAL && renderMode != DWRITE_RENDERING_MODE_ALIASED); }