summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHerbert Dürr <hdu@apache.org>2014-02-20 13:52:52 +0000
committerTor Lillqvist <tml@collabora.com>2014-02-26 13:46:46 +0200
commit3edcdd43f94e605c08314ab61f64c418b01f8dde (patch)
tree9b2bf77108344f7ae7e5ce2dd124b3dd8f3a6d40
parentfe93c38a38a54a479170c1012862518687552c1a (diff)
fdo#64957: #i124233# prevent the accumulation of rounding errors
in CTLayout::FillDXArry() Change-Id: I8ee83068d71275874e4af364df253251dfb41c8c
-rw-r--r--vcl/quartz/ctlayout.cxx16
1 files changed, 12 insertions, 4 deletions
diff --git a/vcl/quartz/ctlayout.cxx b/vcl/quartz/ctlayout.cxx
index 152c1b29870c..1cb8c4825745 100644
--- a/vcl/quartz/ctlayout.cxx
+++ b/vcl/quartz/ctlayout.cxx
@@ -368,9 +368,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 );
@@ -388,9 +387,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;