From 14d52769dca62fd067f8291b57b7e1acb776b46f Mon Sep 17 00:00:00 2001 From: reuk Date: Wed, 28 Aug 2024 16:13:42 +0100 Subject: [PATCH] Direct2D: Revert to using grayscale text antialisaing exclusively Reverts b12088a1f6a405d4ee85f0f2c43afb0babd8a46f After some investigation, it appears that ClearType rendering is unsuitable when - the render target has translucent pixels underneath rendered text, or - the render ouput is rotated, scaled, subpixel-translated, or otherwise transformed before display. This necessitates avoiding ClearType when rendering into transparent bitmaps. Unfortunately, a commmon use-case for transparent bitmaps is buffered component images. Even if ClearType were enabled for opaque targets, ClearType text could then end up displaying next to non-ClearType text rendered to an intermediate texture, leading to an inconsistent appearance. There's also not a straightforward way of exposing a ClearType rendering option in all of the places that it would be required, and a change of this size is difficult to justify given that subpixel text rendering controls would only have an effect on Windows. --- .../native/juce_Direct2DResources_windows.cpp | 2 +- .../juce_graphics/native/juce_DirectX_windows.h | 16 +--------------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/modules/juce_graphics/native/juce_Direct2DResources_windows.cpp b/modules/juce_graphics/native/juce_Direct2DResources_windows.cpp index 58e7091dcf..96b3c4fcb0 100644 --- a/modules/juce_graphics/native/juce_Direct2DResources_windows.cpp +++ b/modules/juce_graphics/native/juce_Direct2DResources_windows.cpp @@ -347,7 +347,7 @@ public: if (const auto hr = result.deviceContext->CreateSolidColorBrush (D2D1::ColorF (0.0f, 0.0f, 0.0f, 1.0f), result.colourBrush.resetAndGetPointerAddress()); - FAILED (hr)) + FAILED (hr)) { jassertfalse; return {}; diff --git a/modules/juce_graphics/native/juce_DirectX_windows.h b/modules/juce_graphics/native/juce_DirectX_windows.h index 720b0bd8b4..a4b72466dc 100644 --- a/modules/juce_graphics/native/juce_DirectX_windows.h +++ b/modules/juce_graphics/native/juce_DirectX_windows.h @@ -348,21 +348,7 @@ struct Direct2DDeviceContext return {}; } - const auto textAntialiasing = [&] - { - BOOL smoothingEnabled{}; - SystemParametersInfo (SPI_GETFONTSMOOTHING, 0, &smoothingEnabled, 0); - - if (! smoothingEnabled) - return D2D1_TEXT_ANTIALIAS_MODE_ALIASED; - - UINT smoothingKind{}; - SystemParametersInfo (SPI_GETFONTSMOOTHINGTYPE, 0, &smoothingKind, 0); - return smoothingKind == FE_FONTSMOOTHINGCLEARTYPE ? D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE - : D2D1_TEXT_ANTIALIAS_MODE_GRAYSCALE; - }(); - - result->SetTextAntialiasMode (textAntialiasing); + result->SetTextAntialiasMode (D2D1_TEXT_ANTIALIAS_MODE_GRAYSCALE); result->SetAntialiasMode (D2D1_ANTIALIAS_MODE_PER_PRIMITIVE); result->SetUnitMode (D2D1_UNIT_MODE_PIXELS);