diff options
author | Mark Hung <marklh9@gmail.com> | 2019-09-23 22:13:10 +0800 |
---|---|---|
committer | Mark Hung <marklh9@gmail.com> | 2019-10-05 00:58:29 +0200 |
commit | 558d1975947efc08db1a2f074351b39b5c4eccb1 (patch) | |
tree | 4e92e93557e17757c1133b8116239272ed78286b | |
parent | ce15460e7b7a5e4930574f88660d03ed3d11fbfe (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>
(cherry picked from commit d744838991594eebe27acc4c7d9fb4579d654853)
Reviewed-on: https://gerrit.libreoffice.org/80221
-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 871f9ce655ca..cc6bb0bb2cff 100644 --- a/sw/source/core/txtnode/fntcache.cxx +++ b/sw/source/core/txtnode/fntcache.cxx @@ -1202,28 +1202,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())); } } } |