diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2024-12-04 14:25:42 +0500 |
---|---|---|
committer | Adolfo Jayme Barrientos <fitojb@ubuntu.com> | 2024-12-06 02:28:07 +0100 |
commit | 84e531c09ada41a1373a629799aef18e229158ac (patch) | |
tree | 6c6f8715953890bf57d063146762a1b6a55ec543 | |
parent | 47a9360de91bb50c19a0d5f2e8408042931933ab (diff) |
Disable subpixel AA in GraphicExporter::filter unconditionally
... in D2DWriteTextOutRenderer.
Commit 785a56b6be7f3128c2e7a131381e02525a50eb6b (D2DWriteTextOutRenderer:
use grayscale AA for file output, 2024-11-27) has disabled it only when
the export settings explicitly specified a concrete AA setting. In case
when the settings didn't specify explicitly, if AA should be used or not,
then system settings were used, which in case of D2DWriteTextOutRenderer
would still enable ClearType (subpixel AA).
This stores additional flag in StyleSettings, similar to what was done
in commit e6538f5bdd876911ea30f84a6512c03908e620fd (tdf#118966 vcl: add
a flag to determine if AA of fonts is used from the system, 2018-07-28),
that tells the renderer to prevent subpixel AA, even if use of AA itself
is defined by system settings. This flag is currently only considered by
D2DWriteTextOutRenderer.
Change-Id: Ibd1879d3c222276eee00c37a442881d6d47c831f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177780
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177791
Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
-rw-r--r-- | include/vcl/settings.hxx | 5 | ||||
-rw-r--r-- | svx/source/unodraw/UnoGraphicExporter.cxx | 11 | ||||
-rw-r--r-- | vcl/source/app/settings.cxx | 15 | ||||
-rw-r--r-- | vcl/win/gdi/DWriteTextRenderer.cxx | 4 |
4 files changed, 30 insertions, 5 deletions
diff --git a/include/vcl/settings.hxx b/include/vcl/settings.hxx index 402a50df6d96..8d34b3ef5d53 100644 --- a/include/vcl/settings.hxx +++ b/include/vcl/settings.hxx @@ -457,6 +457,11 @@ public: void SetUseFontAAFromSystem(bool bUseFontAAFromSystem); bool GetUseFontAAFromSystem() const; + // Using subpixel anti-aliasing is unwanted in some cases, like when saving to file, + // even when the use of anti-aliasing itself is defined by system settings. + void SetUseSubpixelAA(bool val); + bool GetUseSubpixelAA() const; + SAL_DLLPRIVATE void SetUseFlatBorders( bool bUseFlatBorders ); SAL_DLLPRIVATE bool GetUseFlatBorders() const; diff --git a/svx/source/unodraw/UnoGraphicExporter.cxx b/svx/source/unodraw/UnoGraphicExporter.cxx index 541af3219a12..7f412c3b7110 100644 --- a/svx/source/unodraw/UnoGraphicExporter.cxx +++ b/svx/source/unodraw/UnoGraphicExporter.cxx @@ -1004,23 +1004,26 @@ sal_Bool SAL_CALL GraphicExporter::filter( const Sequence< PropertyValue >& aDes AllSettings aAllSettings = Application::GetSettings(); StyleSettings aStyleSettings = aAllSettings.GetStyleSettings(); bool bUseFontAAFromSystem = aStyleSettings.GetUseFontAAFromSystem(); + bool bUseSubpixelAA = aStyleSettings.GetUseSubpixelAA(); + aStyleSettings.SetUseSubpixelAA(false); if (aSettings.meAntiAliasing != TRISTATE_INDET) { // This is safe to do globally as we own the solar mutex. SvtOptionsDrawinglayer::SetAntiAliasing(aSettings.meAntiAliasing == TRISTATE_TRUE, /*bTemporary*/true); // Opt in to have AA affect font rendering as well. aStyleSettings.SetUseFontAAFromSystem(false); - aAllSettings.SetStyleSettings(aStyleSettings); - Application::SetSettings(aAllSettings); } + aAllSettings.SetStyleSettings(aStyleSettings); + Application::SetSettings(aAllSettings); nStatus = GetGraphic( aSettings, aGraphic, bVectorType ) ? ERRCODE_NONE : ERRCODE_GRFILTER_FILTERERROR; if (aSettings.meAntiAliasing != TRISTATE_INDET) { SvtOptionsDrawinglayer::SetAntiAliasing(bAntiAliasing, /*bTemporary*/true); aStyleSettings.SetUseFontAAFromSystem(bUseFontAAFromSystem); - aAllSettings.SetStyleSettings(aStyleSettings); - Application::SetSettings(aAllSettings); } + aStyleSettings.SetUseSubpixelAA(bUseSubpixelAA); + aAllSettings.SetStyleSettings(aStyleSettings); + Application::SetSettings(aAllSettings); } if( nStatus == ERRCODE_NONE ) diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx index 3a9df910c06d..db32481326b9 100644 --- a/vcl/source/app/settings.cxx +++ b/vcl/source/app/settings.cxx @@ -183,6 +183,7 @@ struct ImplStyleData * from system settings. */ bool mbUseFontAAFromSystem; + bool mbUseSubpixelAA; bool mbAutoMnemonic; TriState meUseImagesInMenus; bool mnUseFlatBorders; @@ -609,6 +610,7 @@ ImplStyleData::ImplStyleData( const ImplStyleData& rData ) : mbHighContrast(rData.mbHighContrast), mbUseSystemUIFonts(rData.mbUseSystemUIFonts), mbUseFontAAFromSystem(rData.mbUseFontAAFromSystem), + mbUseSubpixelAA(rData.mbUseSubpixelAA), mbAutoMnemonic(rData.mbAutoMnemonic), meUseImagesInMenus(rData.meUseImagesInMenus), mnUseFlatBorders(rData.mnUseFlatBorders), @@ -747,6 +749,7 @@ void ImplStyleData::SetStandardStyles() mbHighContrast = false; mbUseSystemUIFonts = true; mbUseFontAAFromSystem = true; + mbUseSubpixelAA = true; mnUseFlatBorders = false; mnUseFlatMenus = false; mbPreferredUseImagesInMenus = true; @@ -1720,6 +1723,17 @@ bool StyleSettings::GetUseFontAAFromSystem() const return mxData->mbUseFontAAFromSystem; } +void StyleSettings::SetUseSubpixelAA(bool val) +{ + CopyData(); + mxData->mbUseSubpixelAA = val; +} + +bool StyleSettings::GetUseSubpixelAA() const +{ + return mxData->mbUseSubpixelAA; +} + void StyleSettings::SetUseFlatBorders( bool bUseFlatBorders ) { @@ -2573,6 +2587,7 @@ bool StyleSettings::operator ==( const StyleSettings& rSet ) const (mxData->mbHighContrast == rSet.mxData->mbHighContrast) && (mxData->mbUseSystemUIFonts == rSet.mxData->mbUseSystemUIFonts) && (mxData->mbUseFontAAFromSystem == rSet.mxData->mbUseFontAAFromSystem) && + (mxData->mbUseSubpixelAA == rSet.mxData->mbUseSubpixelAA) && (mxData->mnUseFlatBorders == rSet.mxData->mnUseFlatBorders) && (mxData->mnUseFlatMenus == rSet.mxData->mnUseFlatMenus) && (mxData->maFaceColor == rSet.mxData->maFaceColor) && diff --git a/vcl/win/gdi/DWriteTextRenderer.cxx b/vcl/win/gdi/DWriteTextRenderer.cxx index 06f927b725a6..cb3c1ba4c060 100644 --- a/vcl/win/gdi/DWriteTextRenderer.cxx +++ b/vcl/win/gdi/DWriteTextRenderer.cxx @@ -41,7 +41,9 @@ namespace D2D1_TEXT_ANTIALIAS_MODE lclGetSystemTextAntiAliasType() { UINT t; - if (SystemParametersInfoW(SPI_GETFONTSMOOTHINGTYPE, 0, &t, 0) && t == FE_FONTSMOOTHINGCLEARTYPE) + if (Application::GetSettings().GetStyleSettings().GetUseSubpixelAA() + && SystemParametersInfoW(SPI_GETFONTSMOOTHINGTYPE, 0, &t, 0) + && t == FE_FONTSMOOTHINGCLEARTYPE) return D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE; return D2D1_TEXT_ANTIALIAS_MODE_GRAYSCALE; } |