Author: hdu Date: Thu Feb 20 13:52:52 2014 New Revision: 1570188 URL: http://svn.apache.org/r1570188 Log: #i124233# prevent the accumulation of rounding errors in CTLayout::FillDXArry()
Modified: openoffice/trunk/main/vcl/aqua/source/gdi/ctlayout.cxx Modified: openoffice/trunk/main/vcl/aqua/source/gdi/ctlayout.cxx URL: http://svn.apache.org/viewvc/openoffice/trunk/main/vcl/aqua/source/gdi/ctlayout.cxx?rev=1570188&r1=1570187&r2=1570188&view=diff ============================================================================== --- openoffice/trunk/main/vcl/aqua/source/gdi/ctlayout.cxx (original) +++ openoffice/trunk/main/vcl/aqua/source/gdi/ctlayout.cxx Thu Feb 20 13:52:52 2014 @@ -382,9 +382,8 @@ long CTLayout::FillDXArray( sal_Int32* p 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 ); @@ -402,8 +401,17 @@ long CTLayout::FillDXArray( sal_Int32* p CTRunGetStringIndices( pGlyphRun, aFullRange, &aIndexVec[0] ); for( int i = 0; i != nGlyphCount; ++i ) { const int nRelIdx = aIndexVec[i]; - pDXArray[ nRelIdx ] += 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; } }