drawinglayer/source/processor2d/vclpixelprocessor2d.cxx |    9 ----
 include/vcl/outdev.hxx                                  |    7 ---
 include/vcl/vcllayout.hxx                               |    5 ++
 starmath/source/ElementsDockingWindow.cxx               |    1 
 sw/source/core/txtnode/fntcache.cxx                     |    6 ---
 vcl/inc/salgdi.hxx                                      |   11 -----
 vcl/qa/cppunit/pdfexport/pdfexport.cxx                  |   20 +++++-----
 vcl/qt5/QtGraphics_Text.cxx                             |    3 +
 vcl/quartz/salgdi.cxx                                   |    2 -
 vcl/skia/win/gdiimpl.cxx                                |    2 -
 vcl/skia/x11/textrender.cxx                             |    2 -
 vcl/source/filter/svm/SvmConverter.cxx                  |    1 
 vcl/source/gdi/pdfwriter_impl.cxx                       |   10 ++---
 vcl/source/gdi/salgdilayout.cxx                         |    3 -
 vcl/source/gdi/virdev.cxx                               |    2 -
 vcl/source/outdev/map.cxx                               |   20 +++++++---
 vcl/source/outdev/outdev.cxx                            |   15 -------
 vcl/source/outdev/text.cxx                              |   31 +++++-----------
 vcl/unx/generic/gdi/cairotextrender.cxx                 |    2 -
 vcl/win/gdi/winlayout.cxx                               |    2 -
 20 files changed, 54 insertions(+), 100 deletions(-)

New commits:
commit 100fe8a3a1724f1a5f834da11e17d1641be20994
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Mon Aug 15 17:24:28 2022 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Fri Aug 26 00:36:58 2022 +0200

    automatically set TextRenderModeForResolutionIndependentLayout if we scale
    
    Always render glyphs with a mode suitable for rendering of
    resolution-independent layout positions if we scale the text positions.
    
    The idea being to typically continue to use the system defaults for font
    settings for UI elements, but where we are rendering into application
    canvases where there's a mapmode set then automatically use a good mode
    to render that.
    
    Change-Id: I0e5857e377da72ae1a2ede1d88d6408819fc9200
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138324
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx 
b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
index fe2f30cbf23a..5e0612f94a93 100644
--- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
@@ -75,12 +75,9 @@ namespace drawinglayer::processor2d
 struct VclPixelProcessor2D::Impl
 {
     AntialiasingFlags m_nOrigAntiAliasing;
-    bool m_bOrigTextRenderModeForResolutionIndependentLayout;
 
     explicit Impl(OutputDevice const& rOutDev)
         : m_nOrigAntiAliasing(rOutDev.GetAntialiasing())
-        , m_bOrigTextRenderModeForResolutionIndependentLayout(
-              rOutDev.GetTextRenderModeForResolutionIndependentLayout())
     {
     }
 };
@@ -107,9 +104,6 @@ VclPixelProcessor2D::VclPixelProcessor2D(const 
geometry::ViewInformation2D& rVie
     {
         mpOutputDevice->SetAntialiasing(m_pImpl->m_nOrigAntiAliasing & 
~AntialiasingFlags::Enable);
     }
-
-    // tdf#150462 set text render mode to suit use of resolution independent 
text layout
-    mpOutputDevice->SetTextRenderModeForResolutionIndependentLayout(true);
 }
 
 VclPixelProcessor2D::~VclPixelProcessor2D()
@@ -119,9 +113,6 @@ VclPixelProcessor2D::~VclPixelProcessor2D()
 
     // restore AntiAliasing
     mpOutputDevice->SetAntialiasing(m_pImpl->m_nOrigAntiAliasing);
-
-    mpOutputDevice->SetTextRenderModeForResolutionIndependentLayout(
-        m_pImpl->m_bOrigTextRenderModeForResolutionIndependentLayout);
 }
 
 void VclPixelProcessor2D::tryDrawPolyPolygonColorPrimitive2DDirect(
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index 5a13c640a296..27e7650e8f72 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -236,7 +236,6 @@ private:
     Point                           maRefPoint;
     AntialiasingFlags               mnAntialiasing;
     LanguageType                    meTextLanguage;
-    bool mbTextRenderModeForResolutionIndependentLayout;
 
     mutable bool                    mbMap : 1;
     mutable bool                    mbClipRegion : 1;
@@ -484,10 +483,6 @@ public:
     void                        SetAntialiasing( AntialiasingFlags nMode );
     AntialiasingFlags           GetAntialiasing() const { return 
mnAntialiasing; }
 
-    // Render glyphs with a mode suitable for rendering of 
resolution-independent layout positions.
-    void                        
SetTextRenderModeForResolutionIndependentLayout(bool bMode);
-    bool                        
GetTextRenderModeForResolutionIndependentLayout() const { return 
mbTextRenderModeForResolutionIndependentLayout; }
-
     void                        SetDrawMode( DrawModeFlags nDrawMode );
     DrawModeFlags               GetDrawMode() const { return mnDrawMode; }
 
@@ -1715,7 +1710,7 @@ public:
     SAL_DLLPRIVATE tools::Long         ImplLogicHeightToDevicePixel( 
tools::Long nHeight ) const;
     SAL_DLLPRIVATE double              
ImplLogicHeightToDeviceSubPixel(tools::Long nHeight) const;
 
-    SAL_DLLPRIVATE Point               SubPixelToLogic(const DevicePoint& 
rDevicePt) const;
+    SAL_DLLPRIVATE Point               SubPixelToLogic(const DevicePoint& 
rDevicePt, bool bCheck) const;
 
     /** Convert device pixels to a width in logical units.
 
diff --git a/include/vcl/vcllayout.hxx b/include/vcl/vcllayout.hxx
index cbadb47ee0ba..e63d365b49c4 100644
--- a/include/vcl/vcllayout.hxx
+++ b/include/vcl/vcllayout.hxx
@@ -87,6 +87,11 @@ public:
         mbTextRenderModeForResolutionIndependentLayout = 
bTextRenderModeForResolutionIndependentLayout;
     }
 
+    bool            GetTextRenderModeForResolutionIndependentLayout() const
+    {
+        return mbTextRenderModeForResolutionIndependentLayout;
+    }
+
     // methods using string indexing
     virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, 
DeviceCoordinate nCharExtra, int nFactor) const = 0;
     virtual DeviceCoordinate FillDXArray( std::vector<DeviceCoordinate>* 
pDXArray ) const = 0;
diff --git a/starmath/source/ElementsDockingWindow.cxx 
b/starmath/source/ElementsDockingWindow.cxx
index 202396dfc282..49eea01ddb2a 100644
--- a/starmath/source/ElementsDockingWindow.cxx
+++ b/starmath/source/ElementsDockingWindow.cxx
@@ -506,7 +506,6 @@ void SmElementsControl::addElement(const OUString& 
aElementVisual, const OUStrin
 {
     std::unique_ptr<SmNode> pNode = maParser->ParseExpression(aElementVisual);
     VclPtr<VirtualDevice> pDevice(mpIconView->create_virtual_device());
-    pDevice->SetTextRenderModeForResolutionIndependentLayout(true);
     pDevice->SetMapMode(MapMode(MapUnit::Map100thMM));
     pDevice->SetDrawMode(DrawModeFlags::Default);
     pDevice->SetLayoutMode(vcl::text::ComplexTextLayoutFlags::Default);
diff --git a/sw/source/core/txtnode/fntcache.cxx 
b/sw/source/core/txtnode/fntcache.cxx
index 88d9037a3eb1..146122841e7c 100644
--- a/sw/source/core/txtnode/fntcache.cxx
+++ b/sw/source/core/txtnode/fntcache.cxx
@@ -1182,10 +1182,6 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
 
     else
     {
-        const bool 
bOrigTextRenderModeForResolutionIndependentLayout(rInf.GetOut().GetTextRenderModeForResolutionIndependentLayout());
-        // set text render mode to suit use of resolution independent text 
layout
-        rInf.GetOut().SetTextRenderModeForResolutionIndependentLayout(true);
-
         const OUString* pStr = &rInf.GetText();
 
         OUString aStr;
@@ -1523,8 +1519,6 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
                 }
             }
         }
-
-        
rInf.GetOut().SetTextRenderModeForResolutionIndependentLayout(bOrigTextRenderModeForResolutionIndependentLayout);
     }
 }
 
diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx
index 75938afecece..a050e4588042 100644
--- a/vcl/inc/salgdi.hxx
+++ b/vcl/inc/salgdi.hxx
@@ -96,16 +96,6 @@ public:
         return m_bAntiAlias;
     }
 
-    void setTextRenderModeForResolutionIndependentLayout(bool bNew)
-    {
-        m_bTextRenderModeForResolutionIndependentLayout = bNew;
-    }
-
-    bool getTextRenderModeForResolutionIndependentLayoutEnabled() const
-    {
-        return m_bTextRenderModeForResolutionIndependentLayout;
-    }
-
     // public SalGraphics methods, the interface to the independent vcl part
 
     // get device resolution
@@ -654,7 +644,6 @@ private:
 protected:
     /// flags which hold the SetAntialiasing() value from OutputDevice
     bool                        m_bAntiAlias : 1;
-    bool                        
m_bTextRenderModeForResolutionIndependentLayout : 1;
 
     inline tools::Long GetDeviceWidth(const OutputDevice& rOutDev) const;
 
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index a6d635d21369..057773c3ddaf 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -818,36 +818,36 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf108963)
                 = pPdfPageObject->getPathSegment(0);
             CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFSegmentType::Moveto, 
pSegment->getType());
             basegfx::B2DPoint aPoint = pSegment->getPoint();
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(245.395, aPoint.getX(), 0.0005);
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(244.261, aPoint.getY(), 0.0005);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(245.367, aPoint.getX(), 0.0005);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(244.232, aPoint.getY(), 0.0005);
             CPPUNIT_ASSERT(!pSegment->isClosed());
 
             pSegment = pPdfPageObject->getPathSegment(1);
             CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFSegmentType::Lineto, 
pSegment->getType());
             aPoint = pSegment->getPoint();
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(275.102, aPoint.getX(), 0.0005);
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(267.618, aPoint.getY(), 0.0005);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(275.074, aPoint.getX(), 0.0005);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(267.590, aPoint.getY(), 0.0005);
             CPPUNIT_ASSERT(!pSegment->isClosed());
 
             pSegment = pPdfPageObject->getPathSegment(2);
             CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFSegmentType::Lineto, 
pSegment->getType());
             aPoint = pSegment->getPoint();
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(287.518, aPoint.getX(), 0.0005);
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(251.829, aPoint.getY(), 0.0005);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(287.490, aPoint.getX(), 0.0005);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(251.801, aPoint.getY(), 0.0005);
             CPPUNIT_ASSERT(!pSegment->isClosed());
 
             pSegment = pPdfPageObject->getPathSegment(3);
             CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFSegmentType::Lineto, 
pSegment->getType());
             aPoint = pSegment->getPoint();
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(257.839, aPoint.getX(), 0.0005);
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(228.472, aPoint.getY(), 0.0005);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(257.811, aPoint.getX(), 0.0005);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(228.443, aPoint.getY(), 0.0005);
             CPPUNIT_ASSERT(!pSegment->isClosed());
 
             pSegment = pPdfPageObject->getPathSegment(4);
             CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFSegmentType::Lineto, 
pSegment->getType());
             aPoint = pSegment->getPoint();
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(245.395, aPoint.getX(), 0.0005);
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(244.261, aPoint.getY(), 0.0005);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(245.367, aPoint.getX(), 0.0005);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(244.232, aPoint.getY(), 0.0005);
             CPPUNIT_ASSERT(pSegment->isClosed());
         }
     }
diff --git a/vcl/qt5/QtGraphics_Text.cxx b/vcl/qt5/QtGraphics_Text.cxx
index 940578c5d8bf..03db69dbed6e 100644
--- a/vcl/qt5/QtGraphics_Text.cxx
+++ b/vcl/qt5/QtGraphics_Text.cxx
@@ -320,7 +320,8 @@ void QtGraphics::DrawTextLayout(const GenericSalLayout& 
rLayout)
 {
     const QtFont* pFont = static_cast<const QtFont*>(&rLayout.GetFont());
     assert(pFont);
-    QRawFont aRawFont(GetRawFont(*pFont, 
getTextRenderModeForResolutionIndependentLayoutEnabled()));
+    QRawFont aRawFont(
+        GetRawFont(*pFont, 
rLayout.GetTextRenderModeForResolutionIndependentLayout()));
 
     QVector<quint32> glyphIndexes;
     QVector<QPointF> positions;
diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx
index 1ce488be9c4d..8634bfa8ff9b 100644
--- a/vcl/quartz/salgdi.cxx
+++ b/vcl/quartz/salgdi.cxx
@@ -382,7 +382,7 @@ bool 
AquaSalGraphics::AddTempDevFont(vcl::font::PhysicalFontCollection*,
 
 void AquaSalGraphics::DrawTextLayout(const GenericSalLayout& rLayout)
 {
-    mpBackend->drawTextLayout(rLayout, 
getTextRenderModeForResolutionIndependentLayoutEnabled());
+    mpBackend->drawTextLayout(rLayout, 
rLayout.GetTextRenderModeForResolutionIndependentLayout());
 }
 
 void AquaGraphicsBackend::drawTextLayout(const GenericSalLayout& rLayout, bool 
bTextRenderModeForResolutionIndependentLayout)
diff --git a/vcl/skia/win/gdiimpl.cxx b/vcl/skia/win/gdiimpl.cxx
index 586b4e1fdd97..27a915db1f93 100644
--- a/vcl/skia/win/gdiimpl.cxx
+++ b/vcl/skia/win/gdiimpl.cxx
@@ -267,7 +267,7 @@ bool WinSkiaSalGraphicsImpl::DrawTextLayout(const 
GenericSalLayout& rLayout)
 
     SkFont font(typeface);
 
-    bool bSubpixelPositioning = 
mWinParent.getTextRenderModeForResolutionIndependentLayoutEnabled();
+    bool bSubpixelPositioning = 
rLayout.GetTextRenderModeForResolutionIndependentLayout();
     SkFont::Edging ePreferredAliasing
         = bSubpixelPositioning ? SkFont::Edging::kSubpixelAntiAlias : 
fontEdging;
     if (bSubpixelPositioning)
diff --git a/vcl/skia/x11/textrender.cxx b/vcl/skia/x11/textrender.cxx
index 9fda8ba6601c..3548dc61683e 100644
--- a/vcl/skia/x11/textrender.cxx
+++ b/vcl/skia/x11/textrender.cxx
@@ -58,7 +58,7 @@ void SkiaTextRender::DrawTextLayout(const GenericSalLayout& 
rLayout, const SalGr
     if (rFont.NeedsArtificialBold())
         font.setEmbolden(true);
 
-    bool bSubpixelPositioning = 
rGraphics.getTextRenderModeForResolutionIndependentLayoutEnabled();
+    bool bSubpixelPositioning = 
rLayout.GetTextRenderModeForResolutionIndependentLayout();
     SkFont::Edging ePreferredAliasing
         = bSubpixelPositioning ? SkFont::Edging::kSubpixelAntiAlias : 
SkFont::Edging::kAntiAlias;
     if (bSubpixelPositioning)
diff --git a/vcl/source/filter/svm/SvmConverter.cxx 
b/vcl/source/filter/svm/SvmConverter.cxx
index efc036cc264a..3be4063be853 100644
--- a/vcl/source/filter/svm/SvmConverter.cxx
+++ b/vcl/source/filter/svm/SvmConverter.cxx
@@ -1275,7 +1275,6 @@ bool TestImportSVM(SvStream& rStream)
     SvmReader aReader(rStream);
     aReader.Read(aGDIMetaFile);
     ScopedVclPtrInstance<VirtualDevice> aVDev;
-    aVDev->SetTextRenderModeForResolutionIndependentLayout(true);
     try
     {
         aGDIMetaFile.Play(*aVDev);
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index 1e8fc7fa5ea9..b1c4e0d6272b 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -5945,7 +5945,7 @@ void PDFWriterImpl::drawVerticalGlyphs(
         sal_Int32 nFontHeight )
 {
     tools::Long nXOffset = 0;
-    Point aCurPos(SubPixelToLogic(rGlyphs[0].m_aPos));
+    Point aCurPos(SubPixelToLogic(rGlyphs[0].m_aPos, fAngle == 0.0));
     aCurPos += rAlignOffset;
     for( size_t i = 0; i < rGlyphs.size(); i++ )
     {
@@ -6035,7 +6035,7 @@ void PDFWriterImpl::drawHorizontalGlyphs(
     for( size_t nRun = 0; nRun < aRunEnds.size(); nRun++ )
     {
         // setup text matrix back transformed to current coordinate system
-        Point aCurPos(SubPixelToLogic(rGlyphs[nBeginRun].m_aPos));
+        Point aCurPos(SubPixelToLogic(rGlyphs[nBeginRun].m_aPos, fAngle == 
0.0));
         aCurPos += rAlignOffset;
         // the first run can be set with "Td" operator
         // subsequent use of that operator would move
@@ -6342,7 +6342,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const 
OUString& rText, bool
         // ascent / descent to match the on-screen rendering.
         // This is the top left of the text without ascent / descent.
         DevicePoint aDrawPosition(rLayout.GetDrawPosition());
-        tools::Rectangle aRectangle(SubPixelToLogic(aDrawPosition),
+        tools::Rectangle aRectangle(SubPixelToLogic(aDrawPosition, true),
                                     
Size(ImplDevicePixelToLogicWidth(rLayout.GetTextWidth()), 0));
         aRectangle.AdjustTop(-aRefDevFontMetric.GetAscent());
         // This includes ascent / descent.
@@ -6353,7 +6353,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const 
OUString& rText, bool
         {
             // Adapt rectangle for rotated text.
             tools::Polygon aPolygon(aRectangle);
-            aPolygon.Rotate(SubPixelToLogic(aDrawPosition), 
pFontInstance->mnOrientation);
+            aPolygon.Rotate(SubPixelToLogic(aDrawPosition, true), 
pFontInstance->mnOrientation);
             drawPolygon(aPolygon);
         }
         else
@@ -6474,7 +6474,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const 
OUString& rText, bool
         {
             DevicePoint aStartPt = rLayout.GetDrawPosition();
             int nWidth = rLayout.GetTextWidth() / rLayout.GetUnitsPerPixel();
-            drawTextLine( SubPixelToLogic(aStartPt),
+            drawTextLine( SubPixelToLogic(aStartPt, true),
                           ImplDevicePixelToLogicWidth( nWidth ),
                           eStrikeout, eUnderline, eOverline, bUnderlineAbove );
         }
diff --git a/vcl/source/gdi/salgdilayout.cxx b/vcl/source/gdi/salgdilayout.cxx
index 003e7f4d4c02..f0cdcc2dd1a7 100644
--- a/vcl/source/gdi/salgdilayout.cxx
+++ b/vcl/source/gdi/salgdilayout.cxx
@@ -55,8 +55,7 @@ SalGraphics::SalGraphics()
 :   m_nLayout( SalLayoutFlags::NONE ),
     m_eLastMirrorMode(MirrorMode::NONE),
     m_nLastMirrorTranslation(0),
-    m_bAntiAlias(false),
-    m_bTextRenderModeForResolutionIndependentLayout(false)
+    m_bAntiAlias(false)
 {
     // read global RTL settings
     if( AllSettings::GetLayoutRTL() )
diff --git a/vcl/source/gdi/virdev.cxx b/vcl/source/gdi/virdev.cxx
index e082e4b21e72..d0687faa76b2 100644
--- a/vcl/source/gdi/virdev.cxx
+++ b/vcl/source/gdi/virdev.cxx
@@ -383,8 +383,6 @@ bool VirtualDevice::ImplSetOutputSizePixel( const Size& 
rNewSize, bool bErase,
             mpAlphaVDev->SetMapMode( GetMapMode() );
 
             mpAlphaVDev->SetAntialiasing( GetAntialiasing() );
-
-            
mpAlphaVDev->SetTextRenderModeForResolutionIndependentLayout(GetTextRenderModeForResolutionIndependentLayout());
         }
 
         return true;
diff --git a/vcl/source/outdev/map.cxx b/vcl/source/outdev/map.cxx
index a073b1b029bf..96589cad6ff7 100644
--- a/vcl/source/outdev/map.cxx
+++ b/vcl/source/outdev/map.cxx
@@ -275,15 +275,20 @@ static double ImplLogicToSubPixel(tools::Long n, 
tools::Long nDPI, tools::Long n
 {
     assert(nDPI > 0);
     assert(nMapDenom != 0);
-    return static_cast<double>(n) * nMapNum * nDPI / nMapDenom;
+    double nRet = static_cast<double>(n) * nMapNum * nDPI / nMapDenom;
+    return nRet;
 }
 
-static tools::Long ImplSubPixelToLogic(double n, tools::Long nDPI, tools::Long 
nMapNum,
+static tools::Long ImplSubPixelToLogic(bool bCheck, double n, tools::Long 
nDPI, tools::Long nMapNum,
                                        tools::Long nMapDenom)
 {
     assert(nDPI > 0);
     assert(nMapNum != 0);
-    return std::round(n * nMapDenom / nMapNum / nDPI);
+
+    double nRes = n * nMapDenom / nMapNum / nDPI;
+    tools::Long nRet(std::round(nRes));
+    assert(!bCheck || n == static_cast<double>(nRet) * nMapNum * nDPI / 
nMapDenom); (void)bCheck;
+    return nRet;
 }
 
 static tools::Long ImplPixelToLogic(tools::Long n, tools::Long nDPI, 
tools::Long nMapNum,
@@ -1173,14 +1178,17 @@ Point OutputDevice::PixelToLogic( const Point& 
rDevicePt ) const
                                     maMapRes.mnMapScNumY, 
maMapRes.mnMapScDenomY ) - maMapRes.mnMapOfsY - mnOutOffLogicY );
 }
 
-Point OutputDevice::SubPixelToLogic(const DevicePoint& rDevicePt) const
+Point OutputDevice::SubPixelToLogic(const DevicePoint& rDevicePt, bool bCheck) 
const
 {
     if (!mbMap)
+    {
+        assert(floor(rDevicePt.getX() == rDevicePt.getX()) && 
floor(rDevicePt.getY() == rDevicePt.getY()));
         return Point(rDevicePt.getX(), rDevicePt.getY());
+    }
 
-    return Point(ImplSubPixelToLogic(rDevicePt.getX(), mnDPIX,
+    return Point(ImplSubPixelToLogic(bCheck, rDevicePt.getX(), mnDPIX,
                                      maMapRes.mnMapScNumX, 
maMapRes.mnMapScDenomX) - maMapRes.mnMapOfsX - mnOutOffLogicX,
-                 ImplSubPixelToLogic(rDevicePt.getY(), mnDPIY,
+                 ImplSubPixelToLogic(bCheck, rDevicePt.getY(), mnDPIY,
                                      maMapRes.mnMapScNumY, 
maMapRes.mnMapScDenomY) - maMapRes.mnMapOfsY - mnOutOffLogicY);
 }
 
diff --git a/vcl/source/outdev/outdev.cxx b/vcl/source/outdev/outdev.cxx
index 952d4ac43550..2bb047acc223 100644
--- a/vcl/source/outdev/outdev.cxx
+++ b/vcl/source/outdev/outdev.cxx
@@ -105,7 +105,6 @@ OutputDevice::OutputDevice(OutDevType eOutDevType) :
     meRasterOp                      = RasterOp::OverPaint;
     mnAntialiasing                  = AntialiasingFlags::NONE;
     meTextLanguage                  = LANGUAGE_SYSTEM;  // TODO: get default 
from configuration?
-    mbTextRenderModeForResolutionIndependentLayout = false;
     mbLineColor                     = true;
     mbFillColor                     = true;
     mbInitLineColor                 = true;
@@ -363,20 +362,6 @@ void OutputDevice::SetAntialiasing( AntialiasingFlags 
nMode )
         mpAlphaVDev->SetAntialiasing( nMode );
 }
 
-void OutputDevice::SetTextRenderModeForResolutionIndependentLayout(bool bMode)
-{
-    if (mbTextRenderModeForResolutionIndependentLayout!= bMode)
-    {
-        mbTextRenderModeForResolutionIndependentLayout = bMode;
-
-        if (mpGraphics)
-            mpGraphics->setTextRenderModeForResolutionIndependentLayout(bMode);
-    }
-
-    if (mpAlphaVDev)
-        mpAlphaVDev->SetTextRenderModeForResolutionIndependentLayout(bMode);
-}
-
 void OutputDevice::SetDrawMode(DrawModeFlags nDrawMode)
 {
     mnDrawMode = nDrawMode;
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index 6ca2785e3b1f..0cf0283dc5c7 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -1377,7 +1377,7 @@ std::unique_ptr<SalLayout> OutputDevice::ImplLayout(const 
OUString& rOrigStr,
     vcl::text::ImplLayoutArgs aLayoutArgs = ImplPrepareLayoutArgs( aStr, 
nMinIndex, nLen,
             nPixelWidth, flags, pLayoutCache);
 
-    bool bTextRenderModeForResolutionIndependentLayout(false);
+    bool bHasScaledDXArray(false);
     DeviceCoordinate nEndGlyphCoord(0);
     std::unique_ptr<double[]> xNaturalDXPixelArray;
     if( !pDXArray.empty() )
@@ -1386,23 +1386,11 @@ std::unique_ptr<SalLayout> 
OutputDevice::ImplLayout(const OUString& rOrigStr,
 
         if (mbMap)
         {
-            // convert from logical units to font units
-            if (GetTextRenderModeForResolutionIndependentLayout())
-            {
-                // without rounding, keeping accuracy for lower levels
-                bTextRenderModeForResolutionIndependentLayout = true;
-                for (int i = 0; i < nLen; ++i)
-                    xNaturalDXPixelArray[i] = 
ImplLogicWidthToDeviceSubPixel(pDXArray[i]);
-
-            }
-            else
-            {
-                // with rounding
-                // using base position for better rounding a.k.a. "dancing 
characters"
-                DeviceCoordinate nPixelXOfs2 = 
LogicWidthToDeviceCoordinate(rLogicalPos.X() * 2);
-                for (int i = 0; i < nLen; ++i)
-                    xNaturalDXPixelArray[i] = 
(LogicWidthToDeviceCoordinate((rLogicalPos.X() + pDXArray[i]) * 2) - 
nPixelXOfs2) / 2;
-            }
+            // convert from logical units to font units without rounding,
+            // keeping accuracy for lower levels
+            bHasScaledDXArray = true;
+            for (int i = 0; i < nLen; ++i)
+                xNaturalDXPixelArray[i] = 
ImplLogicWidthToDeviceSubPixel(pDXArray[i]);
         }
         else
         {
@@ -1429,7 +1417,7 @@ std::unique_ptr<SalLayout> OutputDevice::ImplLayout(const 
OUString& rOrigStr,
     if( !pSalLayout )
         return nullptr;
 
-    
pSalLayout->SetTextRenderModeForResolutionIndependentLayout(bTextRenderModeForResolutionIndependentLayout);
+    
pSalLayout->SetTextRenderModeForResolutionIndependentLayout(bHasScaledDXArray);
 
     // do glyph fallback if needed
     // #105768# avoid fallback for very small font sizes
@@ -1444,7 +1432,10 @@ std::unique_ptr<SalLayout> 
OutputDevice::ImplLayout(const OUString& rOrigStr,
     // position, justify, etc. the layout
     pSalLayout->AdjustLayout( aLayoutArgs );
 
-    if (bTextRenderModeForResolutionIndependentLayout)
+    // default to on for pdf export which uses SubPixelToLogic to convert back 
to
+    // the logical coord space, default off for everything else for now unless
+    // a dxarray is provided which has to be scaled
+    if (bHasScaledDXArray || meOutDevType == OUTDEV_PDF)
         pSalLayout->DrawBase() = ImplLogicToDeviceSubPixel(rLogicalPos);
     else
     {
diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx 
b/vcl/unx/generic/gdi/cairotextrender.cxx
index 24e5580e9bdb..006ea2ce8d4a 100644
--- a/vcl/unx/generic/gdi/cairotextrender.cxx
+++ b/vcl/unx/generic/gdi/cairotextrender.cxx
@@ -228,7 +228,7 @@ void CairoTextRender::DrawTextLayout(const 
GenericSalLayout& rLayout, const SalG
 
     const StyleSettings& rStyleSettings = 
Application::GetSettings().GetStyleSettings();
     const bool bDisableAA = !rStyleSettings.GetUseFontAAFromSystem() && 
!rGraphics.getAntiAlias();
-    const bool bResolutionIndependentLayoutEnabled = 
rGraphics.getTextRenderModeForResolutionIndependentLayoutEnabled();
+    const bool bResolutionIndependentLayoutEnabled = 
rLayout.GetTextRenderModeForResolutionIndependentLayout();
 
     const cairo_font_options_t* pFontOptions = 
GetSalInstance()->GetCairoFontOptions();
     if (pFontOptions || bDisableAA || bResolutionIndependentLayoutEnabled)
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 8371c9577225..66e9ac3e3597 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -320,7 +320,7 @@ void WinSalGraphics::DrawTextLayout(const GenericSalLayout& 
rLayout)
     // DWrite text renderer performs vertical writing better except printing.
     const bool bVerticalScreenText
         = !mbPrinter && rLayout.GetFont().GetFontSelectPattern().mbVertical;
-    const bool bRenderingModeNatural = 
getTextRenderModeForResolutionIndependentLayoutEnabled();
+    const bool bRenderingModeNatural = 
rLayout.GetTextRenderModeForResolutionIndependentLayout();
     const bool bUseDWrite = bVerticalScreenText || bRenderingModeNatural;
     DrawTextLayout(rLayout, hDC, bUseDWrite, bRenderingModeNatural);
 

Reply via email to