1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +00:00

Direct2D: Revert to using grayscale text antialisaing exclusively

Reverts b12088a1f6

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.
This commit is contained in:
reuk 2024-08-28 16:13:42 +01:00
parent 735f99418c
commit 14d52769dc
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C
2 changed files with 2 additions and 16 deletions

View file

@ -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 {};

View file

@ -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);