include/vcl/settings.hxx | 5 +++++ svx/source/unodraw/UnoGraphicExporter.cxx | 11 +++++++---- vcl/source/app/settings.cxx | 15 +++++++++++++++ vcl/win/gdi/DWriteTextRenderer.cxx | 4 +++- 4 files changed, 30 insertions(+), 5 deletions(-)
New commits: commit a38038d8e5e6eb87df3238b9f819d8e2e5828aed Author: Mike Kaganski <[email protected]> AuthorDate: Wed Dec 4 14:25:42 2024 +0500 Commit: Mike Kaganski <[email protected]> CommitDate: Wed Dec 4 16:55:13 2024 +0500 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 <[email protected]> diff --git a/include/vcl/settings.hxx b/include/vcl/settings.hxx index 3b8ac61ca586..c18e0004345f 100644 --- a/include/vcl/settings.hxx +++ b/include/vcl/settings.hxx @@ -440,6 +440,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; + void SetUseFlatBorders( bool bUseFlatBorders ); bool GetUseFlatBorders() const; diff --git a/svx/source/unodraw/UnoGraphicExporter.cxx b/svx/source/unodraw/UnoGraphicExporter.cxx index f56f638fa74d..ea4e65e2439d 100644 --- a/svx/source/unodraw/UnoGraphicExporter.cxx +++ b/svx/source/unodraw/UnoGraphicExporter.cxx @@ -994,23 +994,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 a1138de24c4d..6ad2ef728bff 100644 --- a/vcl/source/app/settings.cxx +++ b/vcl/source/app/settings.cxx @@ -180,6 +180,7 @@ struct ImplStyleData * from system settings. */ bool mbUseFontAAFromSystem; + bool mbUseSubpixelAA; bool mbAutoMnemonic; TriState meUseImagesInMenus; bool mnUseFlatBorders; @@ -601,6 +602,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), @@ -735,6 +737,7 @@ void ImplStyleData::SetStandardStyles() mbHighContrast = false; mbUseSystemUIFonts = true; mbUseFontAAFromSystem = true; + mbUseSubpixelAA = true; mnUseFlatBorders = false; mnUseFlatMenus = false; mbPreferredUseImagesInMenus = true; @@ -1669,6 +1672,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 ) { @@ -2511,6 +2525,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 b6c84297cc41..0e63eedd1f9d 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; }
