summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHerbert Dürr <hdu@apache.org>2014-05-19 12:05:27 +0000
committerCaolán McNamara <caolanm@redhat.com>2014-05-29 16:13:51 +0100
commit507efabe8b40e34c2bebfdaa00d4264c5345d3dd (patch)
tree2b120f40f1920df54e6e50d4b28ed606ed3abb67
parent682849828330f959d3a6cd63a45e1e979a1bd24c (diff)
Resolves: #i124922# allow late setting of the font color...
for CoreText-layouted text (cherry picked from commit 42f9768f771457c53a9f1e6a3581b2df9856401f) Conflicts: vcl/aqua/source/gdi/ctfonts.cxx vcl/aqua/source/gdi/ctfonts.hxx vcl/aqua/source/gdi/ctlayout.cxx vcl/source/gdi/outdev3.cxx Change-Id: Ie2685ab80ca87ea72e25f18d02f883fb36c24a36
-rw-r--r--vcl/inc/quartz/salgdi.h2
-rw-r--r--vcl/quartz/ctfonts.cxx14
-rw-r--r--vcl/quartz/ctlayout.cxx9
-rw-r--r--vcl/source/outdev/text.cxx8
4 files changed, 13 insertions, 20 deletions
diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h
index 7451321ed29d..57dec5b59d8c 100644
--- a/vcl/inc/quartz/salgdi.h
+++ b/vcl/inc/quartz/salgdi.h
@@ -106,7 +106,7 @@ public:
bool GetGlyphBoundRect( sal_GlyphId, Rectangle& ) const;
bool GetGlyphOutline( sal_GlyphId, basegfx::B2DPolyPolygon& ) const;
- void SetTextColor( const RGBAColor& );
+ void SetTextColor( const RGBAColor& ) {}
const CoreTextFontData* mpFontData;
/// <1.0: font is squeezed, >1.0 font is stretched, else 1.0
diff --git a/vcl/quartz/ctfonts.cxx b/vcl/quartz/ctfonts.cxx
index bede546c836b..d2e3d3259db2 100644
--- a/vcl/quartz/ctfonts.cxx
+++ b/vcl/quartz/ctfonts.cxx
@@ -100,6 +100,10 @@ CoreTextStyle::CoreTextStyle( const FontSelectPattern& rFSD )
CFDictionarySetValue( mpStyleDict, kCTFontAttributeName, 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
const void* aGFBDescriptors[] = { CTFontDescriptorCreateWithNameAndSize( CFSTR("LastResort"), 0) }; // TODO: use the full GFB list
const int nGfbCount = sizeof(aGFBDescriptors) / sizeof(*aGFBDescriptors);
@@ -218,16 +222,6 @@ bool CoreTextStyle::GetGlyphOutline( sal_GlyphId aGlyphId, basegfx::B2DPolyPolyg
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
{
return new CoreTextFontData( *this);
diff --git a/vcl/quartz/ctlayout.cxx b/vcl/quartz/ctlayout.cxx
index f74b235c3325..347cc5e7fbee 100644
--- a/vcl/quartz/ctlayout.cxx
+++ b/vcl/quartz/ctlayout.cxx
@@ -108,6 +108,7 @@ bool CTLayout::LayoutText( ImplLayoutArgs& rArgs )
m_vRunData.release();
bLayouted = false;
+ // release an eventual older layout
if( mpAttrString )
CFRelease( mpAttrString );
mpAttrString = NULL;
@@ -115,6 +116,7 @@ bool CTLayout::LayoutText( ImplLayoutArgs& rArgs )
CFRelease( mpCTLine );
mpCTLine = NULL;
+ // initialize the new layout
SalLayout::AdjustLayout( rArgs );
mnCharCount = mnEndCharPos - mnMinCharPos;
@@ -338,7 +340,7 @@ void CTLayout::drawCTLine(AquaSalGraphics& rAquaGraphics, CTLineRef ctline, cons
CGContextScaleCTM( rAquaGraphics.mrContext, 1.0, -1.0 );
CGContextSetShouldAntialias( rAquaGraphics.mrContext, !rAquaGraphics.mbNonAntialiasedText );
- // Draw the text
+ // set the text transformation (e.g. position)
CGPoint aTextPos = GetTextDrawPosition();
if( pStyle->mfFontRotation != 0.0 )
@@ -353,7 +355,12 @@ void CTLayout::drawCTLine(AquaSalGraphics& rAquaGraphics, CTLineRef ctline, cons
SAL_INFO( "vcl.ct", "CGContextSetTextPosition(" << rAquaGraphics.mrContext << "," << aTextPos << ")" );
CGContextSetTextPosition( rAquaGraphics.mrContext, aTextPos.x, aTextPos.y );
+
+ // set the text color as fill color (see kCTForegroundColorFromContextAttributeName)
+ CGContextSetFillColor( rAquaGraphics.mrContext, rAquaGraphics.maTextColor.AsArray() );
+
SAL_INFO( "vcl.ct", "CTLineDraw(" << ctline << "," << rAquaGraphics.mrContext << ")" );
+ // draw the text
CTLineDraw( ctline, rAquaGraphics.mrContext );
#ifndef IOS
// request an update of the changed window area
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index c5030ad66200..b7bb028d2963 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -1282,14 +1282,6 @@ SalLayout* OutputDevice::ImplLayout(const OUString& rOrigStr,
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
SalLayout* pSalLayout = mpGraphics->GetTextLayout( aLayoutArgs, 0 );