From 1b119638acd0c1e10fbb83e927231204f4e25b7a Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 12 Mar 2025 16:01:02 +0100 Subject: [PATCH] Revert "Don't support subpixel positioning for color fonts" This reverts commit fd9c9788f73cb088229701dd92443aa04005a4a3. This change failed to consider the fact that color fonts may also contain non-emoji characters and can be used for regular text. In this case, it very much makes sense to support subpixel positioning. If needed, a more specific optimization can be made for emoji characters later, but for now we just revert to fix the regression. Task-number: QTBUG-134626 Pick-to: 6.8 Change-Id: I07fece03d02b62811c2def26c19c5225a08a0037 Reviewed-by: Eirik Aavitsland (cherry picked from commit e72b2f19300f5a5e2b4c58926024ba332d65e75c) 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 | 4 +--- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/gui/text/coretext/qfontengine_coretext_p.h b/src/gui/text/coretext/qfontengine_coretext_p.h index b1a47282aed..fe4d2c6cc56 100644 --- a/src/gui/text/coretext/qfontengine_coretext_p.h +++ b/src/gui/text/coretext/qfontengine_coretext_p.h @@ -56,7 +56,7 @@ public: bool canRender(const QChar *string, int len) const override; int synthesized() const override { return synthesisFlags; } - bool supportsHorizontalSubPixelPositions() const override { return !isColorFont(); } + bool supportsHorizontalSubPixelPositions() const override { return true; } 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 ddbec584929..fc07693ef6a 100644 --- a/src/gui/text/freetype/qfontengine_ft_p.h +++ b/src/gui/text/freetype/qfontengine_ft_p.h @@ -167,9 +167,8 @@ private: QFixed emSquareSize() const override; bool supportsHorizontalSubPixelPositions() const override { - return !isColorFont() - && (default_hint_style == HintLight || - default_hint_style == HintNone); + return 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 e1c060a19da..17b0c431852 100644 --- a/src/gui/text/windows/qwindowsfontenginedirectwrite.cpp +++ b/src/gui/text/windows/qwindowsfontenginedirectwrite.cpp @@ -779,9 +779,7 @@ QImage QWindowsFontEngineDirectWrite::alphaMapForGlyph(glyph_t glyph, bool QWindowsFontEngineDirectWrite::supportsHorizontalSubPixelPositions() const { QFont::HintingPreference hinting = determineHinting(fontDef); - return (!isColorFont() - && hinting != QFont::PreferFullHinting - && !(fontDef.styleStrategy & QFont::NoAntialias)); + return (hinting != QFont::PreferFullHinting && !(fontDef.styleStrategy & QFont::NoAntialias)); } QFontEngine::Properties QWindowsFontEngineDirectWrite::properties() const