include/vcl/settings.hxx                  |    5 +++++
 svx/source/unodraw/UnoGraphicExporter.cxx |   11 +++++++----
 vcl/source/app/settings.cxx               |   13 +++++++++++++
 vcl/win/gdi/DWriteTextRenderer.cxx        |    4 +++-
 4 files changed, 28 insertions(+), 5 deletions(-)

New commits:
commit bc09a4f1ce1f6a714f7827a404aa6317b503d307
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Wed Dec 4 14:25:42 2024 +0500
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Wed Dec 4 12:44:00 2024 +0100

    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.kagan...@collabora.com>

diff --git a/include/vcl/settings.hxx b/include/vcl/settings.hxx
index 432419abc568..401da27abf7d 100644
--- a/include/vcl/settings.hxx
+++ b/include/vcl/settings.hxx
@@ -460,6 +460,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 0ea662b61a1c..e2b6f7ad029b 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 b4b8907f89cf..7d807a7bdae0 100644
--- a/vcl/source/app/settings.cxx
+++ b/vcl/source/app/settings.cxx
@@ -225,6 +225,7 @@ struct ImplStyleData
      * from system settings.
      */
     bool mbUseFontAAFromSystem : 1;
+    bool mbUseSubpixelAA : 1;
     bool mbAutoMnemonic : 1 = true;
     bool mnUseFlatBorders : 1;
     bool mbPreferredUseImagesInMenus : 1;
@@ -584,6 +585,7 @@ void ImplStyleData::SetStandardStyles()
     mbHighContrast                  = false;
     mbUseSystemUIFonts              = true;
     mbUseFontAAFromSystem           = true;
+    mbUseSubpixelAA                 = true;
     mnUseFlatBorders                = false;
     mnUseFlatMenus                  = false;
     mbPreferredUseImagesInMenus     = true;
@@ -1483,6 +1485,16 @@ bool StyleSettings::GetUseFontAAFromSystem() const
     return mxData->mbUseFontAAFromSystem;
 }
 
+void StyleSettings::SetUseSubpixelAA(bool val)
+{
+    mxData->mbUseSubpixelAA = val;
+}
+
+bool StyleSettings::GetUseSubpixelAA() const
+{
+    return mxData->mbUseSubpixelAA;
+}
+
 void
 StyleSettings::SetUseFlatBorders( bool bUseFlatBorders )
 {
@@ -2285,6 +2297,7 @@ bool ImplStyleData::operator==(const ImplStyleData& rSet) 
const
            (mbHighContrast                    == rSet.mbHighContrast)          
           &&
            (mbUseSystemUIFonts                == rSet.mbUseSystemUIFonts)      
           &&
            (mbUseFontAAFromSystem             == rSet.mbUseFontAAFromSystem)   
           &&
+           (mbUseSubpixelAA                   == rSet.mbUseSubpixelAA)         
           &&
            (mnUseFlatBorders                  == rSet.mnUseFlatBorders)        
           &&
            (mnUseFlatMenus                    == rSet.mnUseFlatMenus)          
           &&
            (maColors                          == rSet.maColors)                
           &&
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;
 }

Reply via email to