vcl/inc/quartz/salgdi.h      |    4 ++--
 vcl/inc/skia/osx/gdiimpl.hxx |    3 ++-
 vcl/quartz/salgdi.cxx        |   12 ++++++++++--
 vcl/skia/osx/gdiimpl.cxx     |   11 ++++++++---
 4 files changed, 22 insertions(+), 8 deletions(-)

New commits:
commit d59f1570cb9a49f3daf159b80744e5c93a74dc5a
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Fri Jan 14 10:54:48 2022 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Fri Jan 14 14:50:38 2022 +0100

    respect TextRenderModeForResolutionIndependentLayout for mac too
    
    Change-Id: I1e572bd03387e1708fe75b90c2bce220b41c29e5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128409
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h
index f0aa925c6083..569a14a6d3fc 100644
--- a/vcl/inc/quartz/salgdi.h
+++ b/vcl/inc/quartz/salgdi.h
@@ -297,7 +297,7 @@ public:
                                    const tools::Rectangle &rControlRegion,
                                    ControlState nState,
                                    const ImplControlValue &aValue) = 0;
-    virtual void drawTextLayout(const GenericSalLayout& layout) = 0;
+    virtual void drawTextLayout(const GenericSalLayout& layout, bool 
bTextRenderModeForResolutionIndependentLayout) = 0;
     virtual void Flush() {}
     virtual void Flush( const tools::Rectangle& ) {}
 protected:
@@ -446,7 +446,7 @@ public:
                                    ControlState nState,
                                    const ImplControlValue &aValue) override;
 
-    virtual void drawTextLayout(const GenericSalLayout& layout) override;
+    virtual void drawTextLayout(const GenericSalLayout& layout, bool 
bTextRenderModeForResolutionIndependentLayout) override;
 
     bool supportsOperation(OutDevSupportType eType) const override;
 };
diff --git a/vcl/inc/skia/osx/gdiimpl.hxx b/vcl/inc/skia/osx/gdiimpl.hxx
index e59aa60f56df..71baf24625fc 100644
--- a/vcl/inc/skia/osx/gdiimpl.hxx
+++ b/vcl/inc/skia/osx/gdiimpl.hxx
@@ -38,7 +38,8 @@ public:
                                    const tools::Rectangle& rControlRegion, 
ControlState nState,
                                    const ImplControlValue& aValue) override;
 
-    virtual void drawTextLayout(const GenericSalLayout& layout) override;
+    virtual void drawTextLayout(const GenericSalLayout& layout,
+                                bool 
bTextRenderModeForResolutionIndependentLayout) override;
 
     virtual void Flush() override;
     virtual void Flush(const tools::Rectangle&) override;
diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx
index 5a1051965b6c..cbeaea4fc62b 100644
--- a/vcl/quartz/salgdi.cxx
+++ b/vcl/quartz/salgdi.cxx
@@ -362,10 +362,10 @@ bool 
AquaSalGraphics::AddTempDevFont(vcl::font::PhysicalFontCollection*,
 
 void AquaSalGraphics::DrawTextLayout(const GenericSalLayout& rLayout)
 {
-    mpBackend->drawTextLayout(rLayout);
+    mpBackend->drawTextLayout(rLayout, 
getTextRenderModeForResolutionIndependentLayoutEnabled());
 }
 
-void AquaGraphicsBackend::drawTextLayout(const GenericSalLayout& rLayout)
+void AquaGraphicsBackend::drawTextLayout(const GenericSalLayout& rLayout, bool 
bTextRenderModeForResolutionIndependentLayout)
 {
 #ifdef IOS
     if (!mrShared.checkContext())
@@ -459,6 +459,14 @@ void AquaGraphicsBackend::drawTextLayout(const 
GenericSalLayout& rLayout)
         CGContextSetTextDrawingMode(mrShared.maContextHolder.get(), 
kCGTextFillStroke);
     }
 
+    if (bTextRenderModeForResolutionIndependentLayout)
+    {
+        
CGContextSetAllowsFontSubpixelQuantization(mrShared.maContextHolder.get(), 
false);
+        
CGContextSetShouldSubpixelQuantizeFonts(mrShared.maContextHolder.get(), false);
+        
CGContextSetAllowsFontSubpixelPositioning(mrShared.maContextHolder.get(), true);
+        
CGContextSetShouldSubpixelPositionFonts(mrShared.maContextHolder.get(), true);
+    }
+
     auto aIt = aGlyphOrientation.cbegin();
     while (aIt != aGlyphOrientation.cend())
     {
diff --git a/vcl/skia/osx/gdiimpl.cxx b/vcl/skia/osx/gdiimpl.cxx
index fa3f1c528322..1035d998a1c8 100644
--- a/vcl/skia/osx/gdiimpl.cxx
+++ b/vcl/skia/osx/gdiimpl.cxx
@@ -261,7 +261,8 @@ bool AquaSkiaSalGraphicsImpl::drawNativeControl(ControlType 
nType, ControlPart n
     return bOK;
 }
 
-void AquaSkiaSalGraphicsImpl::drawTextLayout(const GenericSalLayout& rLayout)
+void AquaSkiaSalGraphicsImpl::drawTextLayout(const GenericSalLayout& rLayout,
+                                             bool bSubpixelPositioning)
 {
     const CoreTextStyle& rStyle = *static_cast<const 
CoreTextStyle*>(&rLayout.GetFont());
     const vcl::font::FontSelectPattern& rFontSelect = 
rStyle.GetFontSelectPattern();
@@ -295,8 +296,12 @@ void AquaSkiaSalGraphicsImpl::drawTextLayout(const 
GenericSalLayout& rLayout)
     //    font.setScaleX(rStyle.mfFontStretch); TODO
     if (rStyle.mbFauxBold)
         font.setEmbolden(true);
-    font.setEdging(!mrShared.mbNonAntialiasedText ? SkFont::Edging::kAntiAlias
-                                                  : SkFont::Edging::kAlias);
+
+    SkFont::Edging ePreferredAliasing
+        = bSubpixelPositioning ? SkFont::Edging::kSubpixelAntiAlias : 
SkFont::Edging::kAntiAlias;
+    if (bSubpixelPositioning)
+        font.setSubpixel(true);
+    font.setEdging(mrShared.mbNonAntialiasedText ? SkFont::Edging::kAlias : 
ePreferredAliasing);
 
     // Vertical font, use width as "height".
     SkFont verticalFont(font);

Reply via email to