diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx index 8304746..d28d47d 100644 --- a/vcl/source/gdi/outdev3.cxx +++ b/vcl/source/gdi/outdev3.cxx @@ -5548,8 +5548,41 @@ long OutputDevice::GetTextArray( const OUString& rStr, sal_Int32* pDXAry, // convert virtual char widths to virtual absolute positions if( pDXAry ) + { +#ifdef ENABLE_CORETEXT + // very ugly hack to distribute the rounding errors between the + // floating point-based Core Text glyph widths and the integer-based + // VCL ones + int nSpaces = 0; + long nGlyphWidths = 0; + for (int i = nIndex; i < nLen; ++i) + { + nGlyphWidths += pDXAry[i - nIndex]; + if ((rStr[i] <= 0x0020) // blank + || (rStr[i] >= 0x2000 && rStr[i] <= 0x200F) // whitespace + || (rStr[i] == 0x3000)) // ideographic space + nSpaces++; + } + if (nSpaces) + { + long nDiff = (nWidth - nGlyphWidths) / nSpaces; + if (nDiff) + { + for (int i = nIndex; i < nLen; ++i) + if (rStr[i] <= 0x0020) + pDXAry[i - nIndex] += nDiff; + } + } +#endif + for( int i = 1; i < nLen; ++i ) pDXAry[ i ] += pDXAry[ i-1 ]; +#ifdef ENABLE_CORETEXT + // make sure the last char width equals text width because many places + // in the code assume this + pDXAry[nLen - 1] = nWidth; +#endif + } // convert from font units to logical units if( mbMap )