summaryrefslogtreecommitdiff
path: root/vcl/coretext
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2013-06-30 14:40:37 +0200
committerKhaled Hosny <khaledhosny@eglug.org>2013-06-30 15:07:57 +0200
commitde2cdeabfe18f6fbe2f0f9a7aa5d91bcf88d9fa2 (patch)
tree6b838ffcc5e46d10a43dbaa6bc885ab3ce95f5c9 /vcl/coretext
parent3ed5b347c5916be5c119ecd1fd2239585a512e55 (diff)
Handle synthetic italic with Core Text
Core Text does not fake missing italic and bold (unlike ATSUI), so we have to do it on our own. This commit handles fake italic, bold is a bit harder. Change-Id: I4e705669638f67e3c8ec414f2cadd0c6daea9bcb
Diffstat (limited to 'vcl/coretext')
-rw-r--r--vcl/coretext/ctfonts.cxx16
1 files changed, 11 insertions, 5 deletions
diff --git a/vcl/coretext/ctfonts.cxx b/vcl/coretext/ctfonts.cxx
index 9caf4f4bfd50..f5e1a985212d 100644
--- a/vcl/coretext/ctfonts.cxx
+++ b/vcl/coretext/ctfonts.cxx
@@ -72,15 +72,21 @@ CTTextStyle::CTTextStyle( const FontSelectPattern& rFSD )
mfFontRotation = pReqFont->mnOrientation * (M_PI / 1800.0);
// handle font stretching if any
- const CGAffineTransform* pMatrix = NULL;
- CGAffineTransform aMatrix;
+ CGAffineTransform aMatrix = CGAffineTransformMakeScale(1.0, 1.0);
if( (pReqFont->mnWidth != 0) && (pReqFont->mnWidth != pReqFont->mnHeight) )
{
mfFontStretch = (float)pReqFont->mnWidth / pReqFont->mnHeight;
- aMatrix = CGAffineTransformMakeScale( mfFontStretch, 1.0F );
- pMatrix = &aMatrix;
+ aMatrix = CGAffineTransformConcat(aMatrix, CGAffineTransformMakeScale(mfFontStretch, 1.0F));
}
+ // fake bold
+ if ((pReqFont->GetWeight() >= WEIGHT_BOLD) && (mpFontData->GetWeight() < WEIGHT_SEMIBOLD))
+ /* XXX */;
+ // fake italic
+ if (((pReqFont->GetSlant() == ITALIC_NORMAL) || (pReqFont->GetSlant() == ITALIC_OBLIQUE))
+ && !((mpFontData->GetSlant() == ITALIC_NORMAL) || (mpFontData->GetSlant() == ITALIC_OBLIQUE)))
+ aMatrix = CGAffineTransformConcat(aMatrix, CGAffineTransformMake(1, 0, tanf(14 * acosf(0) / 90), 1, 0, 0));
+
// create the style object for CoreText font attributes
static const CFIndex nMaxDictSize = 16; // TODO: does this really suffice?
mpStyleDict = CFDictionaryCreateMutable( NULL, nMaxDictSize,
@@ -90,7 +96,7 @@ CTTextStyle::CTTextStyle( const FontSelectPattern& rFSD )
CFDictionarySetValue( mpStyleDict, kCTVerticalFormsAttributeName, pCFVertBool );
CTFontDescriptorRef pFontDesc = (CTFontDescriptorRef)mpFontData->GetFontId();
- CTFontRef pNewCTFont = CTFontCreateWithFontDescriptor( pFontDesc, fScaledFontHeight, pMatrix );
+ CTFontRef pNewCTFont = CTFontCreateWithFontDescriptor( pFontDesc, fScaledFontHeight, &aMatrix );
CFDictionarySetValue( mpStyleDict, kCTFontAttributeName, pNewCTFont );
CFRelease( pNewCTFont);