summaryrefslogtreecommitdiff
path: root/cppcanvas
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2024-10-30 09:51:26 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2024-10-31 12:10:52 +0100
commit11b15571475414ef853e21a6c96afa2ac81f848f (patch)
treee32da625489c121001e8436fb693b2a25a1e1b6e /cppcanvas
parentef085d09e0c019f78a3d35f759c8fe567856b615 (diff)
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 <noel.grandin@collabora.co.uk>
Diffstat (limited to 'cppcanvas')
-rw-r--r--cppcanvas/qa/unit/test.cxx4
-rw-r--r--cppcanvas/source/mtfrenderer/implrenderer.cxx15
2 files changed, 6 insertions, 13 deletions
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;i<nLen; i++)
- {
- aStrikeoutCharWidths.push_back(nStrikeoutWidth);
- }
-
- for ( int i = 1;i< nLen; i++ )
- {
- aStrikeoutCharWidths.adjust(i, aStrikeoutCharWidths[i - 1]);
- }
+ for ( int i = 0;i< nLen; i++ )
+ aStrikeoutCharWidths.push_back(nStrikeoutWidth * (i + 1));
pStrikeoutTextAction =
TextActionFactory::createTextAction(
@@ -2566,7 +2559,7 @@ namespace cppcanvas::internal
rVDev.GetTextArray( pAct->GetText(), &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(