[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-4.1' - vcl/coretext

Herbert Dürr hdu at apache.org
Wed Feb 26 04:01:06 PST 2014


 vcl/coretext/ctlayout.cxx |   16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

New commits:
commit 5e142d7ebb0803a04951dc8b478f59d5cc606389
Author: Herbert Dürr <hdu at apache.org>
Date:   Thu Feb 20 13:52:52 2014 +0000

    fdo#64957: #i124233# prevent the accumulation of rounding errors
    
    in CTLayout::FillDXArry()
    
    Change-Id: I492c39bcb32527001aba5054a33c81f5d979adbf

diff --git a/vcl/coretext/ctlayout.cxx b/vcl/coretext/ctlayout.cxx
index 743d66f..72949a0 100644
--- a/vcl/coretext/ctlayout.cxx
+++ b/vcl/coretext/ctlayout.cxx
@@ -385,9 +385,8 @@ long CTLayout::FillDXArray( sal_Int32* pDXArray ) const
 
     long nPixWidth = GetTextWidth();
     if( pDXArray ) {
-        // initialize the result array
-        for( int i = 0; i < mnCharCount; ++i)
-            pDXArray[i] = 0;
+        // prepare the sub-pixel accurate logical-width array
+        ::std::vector<float> aWidthVector( mnCharCount );
         // handle each glyph run
         CFArrayRef aGlyphRuns = CTLineGetGlyphRuns( mpCTLine );
         const int nRunCount = CFArrayGetCount( aGlyphRuns );
@@ -405,9 +404,18 @@ long CTLayout::FillDXArray( sal_Int32* pDXArray ) const
             CTRunGetStringIndices( pGlyphRun, aFullRange, &aIndexVec[0] );
             for( int i = 0; i != nGlyphCount; ++i ) {
                 const int nRelIdx = aIndexVec[i];
-                pDXArray[ nRelIdx ] += lrint(aSizeVec[i].width);
+                aWidthVector[nRelIdx] += aSizeVec[i].width;
             }
         }
+
+        // convert the sub-pixel accurate array into classic pDXArray integers
+        float fWidthSum = 0.0;
+        sal_Int32 nOldDX = 0;
+        for( int i = 0; i < mnCharCount; ++i) {
+            const sal_Int32 nNewDX = rint( fWidthSum += aWidthVector[i]);
+            pDXArray[i] = nNewDX - nOldDX;
+            nOldDX = nNewDX;
+        }
     }
 
     return nPixWidth;


More information about the Libreoffice-commits mailing list