From 11b15571475414ef853e21a6c96afa2ac81f848f Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 30 Oct 2024 09:51:26 +0200 Subject: convert KernArray from sal_Int32 to double which allows us to eliminate a bunch of rounding at various layers, and consequently maintain a lot more precision Change-Id: I911dedd7c041c1d67396c082e5695346ea689acb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175814 Tested-by: Jenkins Reviewed-by: Noel Grandin --- cppcanvas/qa/unit/test.cxx | 4 ++-- cppcanvas/source/mtfrenderer/implrenderer.cxx | 15 ++++----------- 2 files changed, 6 insertions(+), 13 deletions(-) (limited to 'cppcanvas') diff --git a/cppcanvas/qa/unit/test.cxx b/cppcanvas/qa/unit/test.cxx index ad278f10834b..8a2d6af2365b 100644 --- a/cppcanvas/qa/unit/test.cxx +++ b/cppcanvas/qa/unit/test.cxx @@ -129,8 +129,8 @@ CPPUNIT_TEST_FIXTURE(CanvasTest, testTdf155810) pDev->GetTextArray(aText, &aDXArray); auto nKashida = 200; - aDXArray.set(0, aDXArray[0] + nKashida); - aDXArray.set(2, aDXArray[2] + nKashida); + aDXArray[0] += nKashida; + aDXArray[2] += nKashida; aKashidaArray = { true, false, true, false }; pDev->DrawTextArray(Point(0, 0), aText, aDXArray, aKashidaArray, 0, -1); diff --git a/cppcanvas/source/mtfrenderer/implrenderer.cxx b/cppcanvas/source/mtfrenderer/implrenderer.cxx index e9f3bb56e7bc..4a81fb325682 100644 --- a/cppcanvas/source/mtfrenderer/implrenderer.cxx +++ b/cppcanvas/source/mtfrenderer/implrenderer.cxx @@ -991,15 +991,8 @@ namespace cppcanvas::internal nStrikeoutWidth += nInterval; KernArray aStrikeoutCharWidths; - for ( int i = 0;iGetText(), &aDXArray, pAct->GetIndex(), pAct->GetLen() ); - const sal_Int32 nWidthDifference( pAct->GetWidth() - aDXArray[ nLen-1 ] ); + const double nWidthDifferencePerDx = ( pAct->GetWidth() - aDXArray[ nLen-1 ] ) / nLen; // Last entry of pDXArray contains total width of the text for (sal_Int32 i = 1; i <= nLen; ++i) @@ -2577,7 +2570,7 @@ namespace cppcanvas::internal // entry represents the 'end' position of // the corresponding character, thus, we // let i run from 1 to nLen. - aDXArray.adjust(i - 1, i * nWidthDifference / nLen); + aDXArray[i - 1] += i * nWidthDifferencePerDx; } createTextAction( -- cgit v1.2.3