vcl/qa/cppunit/pdfexport/pdfexport.cxx |    8 ++++----
 vcl/source/gdi/CommonSalLayout.cxx     |    2 +-
 vcl/source/gdi/sallayout.cxx           |   13 +++++++++++--
 3 files changed, 16 insertions(+), 7 deletions(-)

New commits:
commit 0b5d67a3514f6b5f183733fa994906b9af47bbfe
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Wed Aug 23 10:36:41 2023 +0200
Commit:     Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
CommitDate: Wed Aug 30 12:27:01 2023 +0200

    tdf#156681: Revert "tdf#152048: Fix underline width for Kashida-justified 
text"
    
    This reverts commit 43a5400063b17ed4ba4cbb38bdf5da4a991f60e2.
    
    The idea is to revert it in libreoffice-7-6 and libreoffice-7-5 branches
    only since tdf#156681 is fixed in master by 
507a8745870e9a755be3a72f59c6e9a9d811fdcf
    "vcl: Use doubles for glyph item coordinates"
    
    This commit also reverts 34df6c92e513c5f428eff7c9cb1d6b9831eeb323
    "tdf#152048: Add test"
    
    Change-Id: Id246c388df45d16b9bce86d1827949c644fc8517
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155969
    Tested-by: Jenkins
    Reviewed-by: خالد حسني <kha...@libreoffice.org>
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155972
    (cherry picked from commit d6f25135126b6506543e14d0208aea253ea8d085)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155926
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    Tested-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
    Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com>

diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index bf35818056df..d5d8408630aa 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -774,15 +774,15 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf108963)
             pSegment = pPdfPageObject->getPathSegment(1);
             CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFSegmentType::Lineto, 
pSegment->getType());
             aPoint = pSegment->getPoint();
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(275.216, aPoint.getX(), 0.0005);
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(267.732, 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.660, aPoint.getX(), 0.0005);
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(251.914, 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);
diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index 754b228f8ad3..be301edcd365 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -845,7 +845,7 @@ void GenericSalLayout::ApplyDXArray(const double* pDXArray, 
const sal_Bool* pKas
         aPos.adjustX(-nClusterWidth + pGlyphIter->origWidth());
         while (nCopies--)
         {
-            GlyphItem aKashida(nCharPos, 0, nKashidaIndex, aPos, nFlags, 0, 0, 
0);
+            GlyphItem aKashida(nCharPos, 0, nKashidaIndex, aPos, nFlags, 
nKashidaWidth, 0, 0);
             pGlyphIter = m_GlyphItems.insert(pGlyphIter, aKashida);
             aPos.adjustX(nKashidaWidth - nOverlap);
             ++pGlyphIter;
diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
index 3cdd71642b5b..ed368f04022e 100644
--- a/vcl/source/gdi/sallayout.cxx
+++ b/vcl/source/gdi/sallayout.cxx
@@ -269,10 +269,19 @@ DeviceCoordinate GenericSalLayout::GetTextWidth() const
     if (!m_GlyphItems.IsValid())
         return 0;
 
-    DeviceCoordinate nWidth = 0;
+    // initialize the extent
+    DeviceCoordinate nMinPos = 0;
+    DeviceCoordinate nMaxPos = 0;
+
     for (auto const& aGlyphItem : m_GlyphItems)
-        nWidth += aGlyphItem.newWidth();
+    {
+        // update the text extent with the glyph extent
+        DeviceCoordinate nXPos = aGlyphItem.linearPos().getX() - 
aGlyphItem.xOffset();
+        nMinPos = std::min(nMinPos, nXPos);
+        nMaxPos = std::max(nMaxPos, nXPos + aGlyphItem.newWidth());
+    }
 
+    DeviceCoordinate nWidth = nMaxPos - nMinPos;
     return nWidth;
 }
 

Reply via email to