diff options
author | Mark Hung <marklh9@gmail.com> | 2019-09-23 22:13:10 +0800 |
---|---|---|
committer | Mark Hung <marklh9@gmail.com> | 2019-09-29 05:44:27 +0200 |
commit | d744838991594eebe27acc4c7d9fb4579d654853 (patch) | |
tree | 4e6ca56ae8d992357e2e1dd22d502a0f2a3495b1 | |
parent | f4a07458fbf1679ce1f115ecbed16d47ccbc530d (diff) |
tdf#127422 draw text with correct pKernArray values.
Prior to 5f62b97ae7891b8c601f6093a1ec5358feb20790,
Starting position was specified and DrawText was used to render
the text without referring to pKernArray. After the patch,
DrawTextArray was used but pKernArray was not update correctly.
Instead of draw each substring seprated by space, this patch
increases the values pKernArray when a space is encountered
and call DrawTextArray only once.
Change-Id: I9e61b2d0608400f26136490248740c5f00b56cc3
Reviewed-on: https://gerrit.libreoffice.org/79544
Tested-by: Jenkins
Reviewed-by: Mark Hung <marklh9@gmail.com>
-rw-r--r-- | sw/source/core/txtnode/fntcache.cxx | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx index a73ebe3ce9ec..085317e4a259 100644 --- a/sw/source/core/txtnode/fntcache.cxx +++ b/sw/source/core/txtnode/fntcache.cxx @@ -1203,28 +1203,20 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf ) } else { - Point aTmpPos( aTextOriginPos ); sal_Int32 i; - sal_Int32 j = 0; long nSpaceSum = 0; - for (i = 0; i < sal_Int32(rInf.GetLen()); i++ ) + for (i = 0; i < sal_Int32(rInf.GetLen()); i++) { - if( CH_BLANK == rInf.GetText()[ sal_Int32(rInf.GetIdx()) + i ] ) - { - nSpaceSum += nSpaceAdd; - if( j < i) - rInf.GetOut().DrawTextArray( aTmpPos, rInf.GetText(), - pKernArray.get() + j, - sal_Int32(rInf.GetIdx()) + j, i - j ); - j = i + 1; - pKernArray[i] = pKernArray[i] + nSpaceSum; - aTmpPos.setX( aTextOriginPos.X() + pKernArray[ i ] + nKernSum ); - } + if(CH_BLANK == rInf.GetText()[sal_Int32(rInf.GetIdx()) + i]) + nSpaceSum += nSpaceAdd + nKernSum; + + pKernArray[i] += nSpaceSum; } - if( j < i ) - rInf.GetOut().DrawTextArray( aTmpPos, rInf.GetText(), - pKernArray.get() + j, - sal_Int32(rInf.GetIdx()) + j, i - j ); + + rInf.GetOut().DrawTextArray(aTextOriginPos, + rInf.GetText(), pKernArray.get(), + sal_Int32(rInf.GetIdx()), + sal_Int32(rInf.GetLen())); } } } |