vcl/qa/cppunit/complextext.cxx | 38 --------------------------------- vcl/qa/cppunit/pdfexport/pdfexport.cxx | 8 +++--- vcl/source/gdi/CommonSalLayout.cxx | 2 - vcl/source/gdi/sallayout.cxx | 13 +++++++++-- 4 files changed, 16 insertions(+), 45 deletions(-)
New commits: commit 8e5534b478efe4f383f214b9ab41fd3383e98296 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Wed Aug 23 10:36:41 2023 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Wed Aug 23 12:00:34 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> diff --git a/vcl/qa/cppunit/complextext.cxx b/vcl/qa/cppunit/complextext.cxx index 5c6297ec108e..423192a8fd49 100644 --- a/vcl/qa/cppunit/complextext.cxx +++ b/vcl/qa/cppunit/complextext.cxx @@ -381,44 +381,6 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testGdefCaret) #endif } -CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testTdf152048) -{ -#if HAVE_MORE_FONTS - OUString aText(u"میشود"); - - vcl::Font aFont(u"Noto Naskh Arabic", u"Regular", Size(0, 72)); - - ScopedVclPtrInstance<VirtualDevice> pOutDev; - pOutDev->SetFont(aFont); - - // get an compare the default text array - std::vector<sal_Int32> aRefCharWidths{ 33, 82, 82, 129, 163, 193 }; - tools::Long nRefTextWidth(193); - - KernArray aCharWidths; - tools::Long nTextWidth = pOutDev->GetTextArray(aText, &aCharWidths); - - CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths.get_subunit_array()); - CPPUNIT_ASSERT_EQUAL(nRefTextWidth, nTextWidth); - CPPUNIT_ASSERT_EQUAL(sal_Int32(nTextWidth), aCharWidths.back()); - - // Simulate Kashida insertion using Kashida array and extending text array - // to have room for Kashida. - std::vector<sal_Bool> aKashidaArray{ false, false, false, true, false, false }; - auto nKashida = 200; - - aCharWidths.set(3, aCharWidths[3] + nKashida); - aCharWidths.set(4, aCharWidths[4] + nKashida); - aCharWidths.set(5, aCharWidths[5] + nKashida); - auto pLayout = pOutDev->ImplLayout(aText, 0, -1, Point(0, 0), 0, aCharWidths, aKashidaArray); - - // Without the fix this fails with: - // - Expected: 393 - // - Actual : 511 - CPPUNIT_ASSERT_EQUAL(DeviceCoordinate(nRefTextWidth + nKashida), pLayout->GetTextWidth()); -#endif -} - CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testTdf152048_2) { #if HAVE_MORE_FONTS diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index 31ee1e44fed7..af246efd8b39 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -777,15 +777,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 944587f17c8c..faa127e5a925 100644 --- a/vcl/source/gdi/CommonSalLayout.cxx +++ b/vcl/source/gdi/CommonSalLayout.cxx @@ -849,7 +849,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; }