Kaydet (Commit) 5bc53876 authored tarafından Herbert Dürr's avatar Herbert Dürr Kaydeden (comit) Andras Timar

Resolves: #i124922# allow late setting of the font color...

for CoreText-layouted text

(cherry picked from commit 42f9768f)

Conflicts:
	vcl/aqua/source/gdi/ctfonts.cxx
	vcl/aqua/source/gdi/ctfonts.hxx
	vcl/aqua/source/gdi/ctlayout.cxx
	vcl/source/gdi/outdev3.cxx

(cherry picked from commit 507efabe)

Conflicts:
	vcl/quartz/ctlayout.cxx

Change-Id: Ie2685ab80ca87ea72e25f18d02f883fb36c24a36
üst f47e11a0
...@@ -106,7 +106,7 @@ public: ...@@ -106,7 +106,7 @@ public:
bool GetGlyphBoundRect( sal_GlyphId, Rectangle& ) const; bool GetGlyphBoundRect( sal_GlyphId, Rectangle& ) const;
bool GetGlyphOutline( sal_GlyphId, basegfx::B2DPolyPolygon& ) const; bool GetGlyphOutline( sal_GlyphId, basegfx::B2DPolyPolygon& ) const;
void SetTextColor( const RGBAColor& ); void SetTextColor( const RGBAColor& ) {}
const CoreTextFontData* mpFontData; const CoreTextFontData* mpFontData;
/// <1.0: font is squeezed, >1.0 font is stretched, else 1.0 /// <1.0: font is squeezed, >1.0 font is stretched, else 1.0
......
...@@ -100,6 +100,10 @@ CoreTextStyle::CoreTextStyle( const FontSelectPattern& rFSD ) ...@@ -100,6 +100,10 @@ CoreTextStyle::CoreTextStyle( const FontSelectPattern& rFSD )
CFDictionarySetValue( mpStyleDict, kCTFontAttributeName, pNewCTFont ); CFDictionarySetValue( mpStyleDict, kCTFontAttributeName, pNewCTFont );
CFRelease( pNewCTFont); CFRelease( pNewCTFont);
// allow delayed setting the font color, i.e. after the text layout
CFDictionarySetValue( mpStyleDict, kCTForegroundColorFromContextAttributeName, kCFBooleanTrue );
#if 0 // LastResort is implicit in CoreText's font cascading #if 0 // LastResort is implicit in CoreText's font cascading
const void* aGFBDescriptors[] = { CTFontDescriptorCreateWithNameAndSize( CFSTR("LastResort"), 0) }; // TODO: use the full GFB list const void* aGFBDescriptors[] = { CTFontDescriptorCreateWithNameAndSize( CFSTR("LastResort"), 0) }; // TODO: use the full GFB list
const int nGfbCount = sizeof(aGFBDescriptors) / sizeof(*aGFBDescriptors); const int nGfbCount = sizeof(aGFBDescriptors) / sizeof(*aGFBDescriptors);
...@@ -218,16 +222,6 @@ bool CoreTextStyle::GetGlyphOutline( sal_GlyphId aGlyphId, basegfx::B2DPolyPolyg ...@@ -218,16 +222,6 @@ bool CoreTextStyle::GetGlyphOutline( sal_GlyphId aGlyphId, basegfx::B2DPolyPolyg
return true; return true;
} }
void CoreTextStyle::SetTextColor( const RGBAColor& rColor )
{
CGFloat aColor[] = { rColor.GetRed(), rColor.GetGreen(), rColor.GetBlue(), rColor.GetAlpha() };
CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
CGColorRef pCGColor = CGColorCreate( cs, aColor );
CGColorSpaceRelease( cs );
CFDictionarySetValue( mpStyleDict, kCTForegroundColorAttributeName, pCGColor );
CFRelease( pCGColor);
}
PhysicalFontFace* CoreTextFontData::Clone( void ) const PhysicalFontFace* CoreTextFontData::Clone( void ) const
{ {
return new CoreTextFontData( *this); return new CoreTextFontData( *this);
......
...@@ -106,6 +106,7 @@ bool CTLayout::LayoutText( ImplLayoutArgs& rArgs ) ...@@ -106,6 +106,7 @@ bool CTLayout::LayoutText( ImplLayoutArgs& rArgs )
m_vRunData.release(); m_vRunData.release();
bLayouted = false; bLayouted = false;
// release an eventual older layout
if( mpAttrString ) if( mpAttrString )
CFRelease( mpAttrString ); CFRelease( mpAttrString );
mpAttrString = NULL; mpAttrString = NULL;
...@@ -113,6 +114,7 @@ bool CTLayout::LayoutText( ImplLayoutArgs& rArgs ) ...@@ -113,6 +114,7 @@ bool CTLayout::LayoutText( ImplLayoutArgs& rArgs )
CFRelease( mpCTLine ); CFRelease( mpCTLine );
mpCTLine = NULL; mpCTLine = NULL;
// initialize the new layout
SalLayout::AdjustLayout( rArgs ); SalLayout::AdjustLayout( rArgs );
mnCharCount = mnEndCharPos - mnMinCharPos; mnCharCount = mnEndCharPos - mnMinCharPos;
...@@ -328,7 +330,7 @@ void CTLayout::drawCTLine(AquaSalGraphics& rAquaGraphics, CTLineRef ctline, cons ...@@ -328,7 +330,7 @@ void CTLayout::drawCTLine(AquaSalGraphics& rAquaGraphics, CTLineRef ctline, cons
CGContextScaleCTM( rAquaGraphics.mrContext, 1.0, -1.0 ); CGContextScaleCTM( rAquaGraphics.mrContext, 1.0, -1.0 );
CGContextSetShouldAntialias( rAquaGraphics.mrContext, !rAquaGraphics.mbNonAntialiasedText ); CGContextSetShouldAntialias( rAquaGraphics.mrContext, !rAquaGraphics.mbNonAntialiasedText );
// Draw the text // set the text transformation (e.g. position)
CGPoint aTextPos = GetTextDrawPosition(); CGPoint aTextPos = GetTextDrawPosition();
if( pStyle->mfFontRotation != 0.0 ) if( pStyle->mfFontRotation != 0.0 )
...@@ -341,6 +343,11 @@ void CTLayout::drawCTLine(AquaSalGraphics& rAquaGraphics, CTLineRef ctline, cons ...@@ -341,6 +343,11 @@ void CTLayout::drawCTLine(AquaSalGraphics& rAquaGraphics, CTLineRef ctline, cons
} }
CGContextSetTextPosition( rAquaGraphics.mrContext, aTextPos.x, aTextPos.y ); CGContextSetTextPosition( rAquaGraphics.mrContext, aTextPos.x, aTextPos.y );
// set the text color as fill color (see kCTForegroundColorFromContextAttributeName)
CGContextSetFillColor( rAquaGraphics.mrContext, rAquaGraphics.maTextColor.AsArray() );
// draw the text
CTLineDraw( ctline, rAquaGraphics.mrContext ); CTLineDraw( ctline, rAquaGraphics.mrContext );
#ifndef IOS #ifndef IOS
// request an update of the changed window area // request an update of the changed window area
......
...@@ -1282,14 +1282,6 @@ SalLayout* OutputDevice::ImplLayout(const OUString& rOrigStr, ...@@ -1282,14 +1282,6 @@ SalLayout* OutputDevice::ImplLayout(const OUString& rOrigStr,
ImplLayoutArgs aLayoutArgs = ImplPrepareLayoutArgs( aStr, nMinIndex, nLen, nPixelWidth, pDXArray ); ImplLayoutArgs aLayoutArgs = ImplPrepareLayoutArgs( aStr, nMinIndex, nLen, nPixelWidth, pDXArray );
#if defined(MACOSX) || defined(IOS)
// CoreText layouts are immutable and already contain the text color
// so we need to provide the color already for the layout request
// even if this layout will never be drawn
if( mbInitTextColor )
const_cast<OutputDevice&>(*this).ImplInitTextColor();
#endif
// get matching layout object for base font // get matching layout object for base font
SalLayout* pSalLayout = mpGraphics->GetTextLayout( aLayoutArgs, 0 ); SalLayout* pSalLayout = mpGraphics->GetTextLayout( aLayoutArgs, 0 );
......
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