Kaydet (Commit) fec3f8a8 authored tarafından Tor Lillqvist's avatar Tor Lillqvist

Much better fix for the iOS text colour problem

Just use the same simple trick as for OS X in
OutputDevice::ImplLayout().

Thanks to Khaled Hosny for pointing out this.

This reverts commit 9aba69e8cc034526c53f6135a41fc62dc3c5dce3.

Change-Id: I27ba92ef8ebd1ebdb9eb74f670d8170649078881
üst 62ea355b
...@@ -64,8 +64,6 @@ private: ...@@ -64,8 +64,6 @@ private:
// mutable members since these details are all lazy initialized // mutable members since these details are all lazy initialized
mutable double mfCachedWidth; // cached value of resulting typographical width mutable double mfCachedWidth; // cached value of resulting typographical width
mutable float mfAdjustedLineLength;
// x-offset relative to layout origin // x-offset relative to layout origin
// currently only used in RTL-layouts // currently only used in RTL-layouts
mutable double mfBaseAdv; mutable double mfBaseAdv;
...@@ -77,7 +75,6 @@ CTLayout::CTLayout( const CoreTextStyle* pTextStyle ) ...@@ -77,7 +75,6 @@ CTLayout::CTLayout( const CoreTextStyle* pTextStyle )
, mpCTLine( NULL ) , mpCTLine( NULL )
, mnCharCount( 0 ) , mnCharCount( 0 )
, mfCachedWidth( -1 ) , mfCachedWidth( -1 )
, mfAdjustedLineLength( 0 )
, mfBaseAdv( 0 ) , mfBaseAdv( 0 )
{ {
} }
...@@ -162,7 +159,6 @@ void CTLayout::AdjustLayout( ImplLayoutArgs& rArgs ) ...@@ -162,7 +159,6 @@ void CTLayout::AdjustLayout( ImplLayoutArgs& rArgs )
CFRelease( mpCTLine ); CFRelease( mpCTLine );
mpCTLine = pNewCTLine; mpCTLine = pNewCTLine;
mfCachedWidth = nPixelWidth; mfCachedWidth = nPixelWidth;
mfAdjustedLineLength = nPixelWidth - fTrailingSpace;
} }
// When drawing right aligned text, rounding errors in the position returned by // When drawing right aligned text, rounding errors in the position returned by
...@@ -225,36 +221,7 @@ void CTLayout::DrawText( SalGraphics& rGraphics ) const ...@@ -225,36 +221,7 @@ void CTLayout::DrawText( SalGraphics& rGraphics ) const
} }
CGContextSetTextPosition( rAquaGraphics.mrContext, aTextPos.x, aTextPos.y ); CGContextSetTextPosition( rAquaGraphics.mrContext, aTextPos.x, aTextPos.y );
#ifdef MACOSX
// For some reason on OS X the problem with text colour being out of sync
// does not seem to occur.
CTLineDraw( mpCTLine, rAquaGraphics.mrContext ); CTLineDraw( mpCTLine, rAquaGraphics.mrContext );
#else
if( CFDictionaryGetValue( mpTextStyle->GetStyleDict(), kCTFontAttributeName) )
{
// We did likely not know the correct intended colour of the
// text in LayoutText(), so have to redo layout and justify.
CFStringRef aCFText = CFAttributedStringGetString( mpAttrString );
CFAttributedStringRef pAttrString = CFAttributedStringCreate( NULL, aCFText, mpTextStyle->GetStyleDict() );
CTLineRef pCTLine = CTLineCreateWithAttributedString( pAttrString );
CFRelease( pAttrString );
if( mfAdjustedLineLength > 0 )
{
CTLineRef pNewCTLine = CTLineCreateJustifiedLine( pCTLine, 1.0, mfAdjustedLineLength );
CFRelease( pCTLine );
pCTLine = pNewCTLine;
}
CTLineDraw( pCTLine, rAquaGraphics.mrContext );
CFRelease( pCTLine );
}
else
{
// FIXME: can the colour be wrong also the other way around:
// some leftover wrong colour was used in LayoutText(), but
// then here the style does not actually contain any colour?
CTLineDraw( mpCTLine, rAquaGraphics.mrContext );
}
#endif
#ifndef IOS #ifndef IOS
// request an update of the changed window area // request an update of the changed window area
if( rAquaGraphics.IsWindowGraphics() ) if( rAquaGraphics.IsWindowGraphics() )
......
...@@ -5783,7 +5783,7 @@ SalLayout* OutputDevice::ImplLayout( const OUString& rOrigStr, sal_Int32 nMinInd ...@@ -5783,7 +5783,7 @@ SalLayout* OutputDevice::ImplLayout( const OUString& rOrigStr, sal_Int32 nMinInd
ImplLayoutArgs aLayoutArgs = ImplPrepareLayoutArgs( aStr, nMinIndex, nLen, nPixelWidth, pDXArray ); ImplLayoutArgs aLayoutArgs = ImplPrepareLayoutArgs( aStr, nMinIndex, nLen, nPixelWidth, pDXArray );
#ifdef MACOSX #if defined(MACOSX) || defined(IOS)
// CoreText layouts are immutable and already contain the text color // CoreText layouts are immutable and already contain the text color
// so we need to provide the color already for the layout request // so we need to provide the color already for the layout request
// even if this layout will never be drawn // even if this layout will never be drawn
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment