[Libreoffice-commits] core.git: Branch 'libreoffice-4-2-2' - vcl/coretext

Herbert Dürr hdu at apache.org
Wed Feb 26 07:18:02 PST 2014


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

New commits:
commit ac7062d7fb6e5dfe0f81d53daec7f088dc4f9e3d
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: Ifb4f16fb76f67d5b5c96fdb0545c64eb8316aa3c
    Reviewed-on: https://gerrit.libreoffice.org/8359
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    Reviewed-on: https://gerrit.libreoffice.org/8366
    Reviewed-by: David Tardon <dtardon at redhat.com>

diff --git a/vcl/coretext/ctlayout.cxx b/vcl/coretext/ctlayout.cxx
index 0e9a6e0..d248c48 100644
--- a/vcl/coretext/ctlayout.cxx
+++ b/vcl/coretext/ctlayout.cxx
@@ -369,9 +369,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 );
@@ -389,9 +388,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