vcl/coretext/ctfonts.cxx | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-)
New commits: commit 87daa3c948eaa928591d95c9528922471fde57c1 Author: Khaled Hosny <khaledho...@eglug.org> Date: Sun Jun 30 14:40:37 2013 +0200 Handle synthetic bold italic with Core Text Core Text does not fake missing italic and bold (unlike ATSUI), so we have to do it on our own. Change-Id: Ia5977d53739b7a6eaaccbf3aeb24adb820ca05c6 Reviewed-on: https://gerrit.libreoffice.org/4658 Reviewed-by: David Tardon <dtar...@redhat.com> Tested-by: David Tardon <dtar...@redhat.com> diff --git a/vcl/coretext/ctfonts.cxx b/vcl/coretext/ctfonts.cxx index 5d8c0e7..a0cc98a 100644 --- a/vcl/coretext/ctfonts.cxx +++ b/vcl/coretext/ctfonts.cxx @@ -58,6 +58,11 @@ private: // ======================================================================= +inline double toRadian(int nDegree) +{ + return nDegree * (M_PI / 1800.0); +} + CTTextStyle::CTTextStyle( const FontSelectPattern& rFSD ) : ImplMacTextStyle( rFSD ) , mpStyleDict( NULL ) @@ -68,16 +73,16 @@ CTTextStyle::CTTextStyle( const FontSelectPattern& rFSD ) double fScaledFontHeight = pReqFont->mfExactHeight; // convert font rotation to radian - mfFontRotation = pReqFont->mnOrientation * (M_PI / 1800.0); + mfFontRotation = toRadian(pReqFont->mnOrientation); + + // dummy matrix so we can use CGAffineTransformConcat() below + CGAffineTransform aMatrix = CGAffineTransformMakeTranslation(0, 0); // handle font stretching if any - const CGAffineTransform* pMatrix = NULL; - CGAffineTransform aMatrix; 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)); } // create the style object for CoreText font attributes @@ -88,8 +93,23 @@ CTTextStyle::CTTextStyle( const FontSelectPattern& rFSD ) CFBooleanRef pCFVertBool = pReqFont->mbVertical ? kCFBooleanTrue : kCFBooleanFalse; CFDictionarySetValue( mpStyleDict, kCTVerticalFormsAttributeName, pCFVertBool ); + // fake bold + if ((pReqFont->GetWeight() >= WEIGHT_BOLD) && (mpFontData->GetWeight() < WEIGHT_SEMIBOLD)) + { + int nStroke = -10.0; + CFNumberRef rStroke = CFNumberCreate(NULL, kCFNumberSInt32Type, &nStroke); + CFDictionarySetValue(mpStyleDict, kCTStrokeWidthAttributeName, rStroke); + } + + // 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, toRadian(120), 1, 0, 0)); + } + CTFontDescriptorRef pFontDesc = (CTFontDescriptorRef)mpFontData->GetFontId(); - CTFontRef pNewCTFont = CTFontCreateWithFontDescriptor( pFontDesc, fScaledFontHeight, pMatrix ); + CTFontRef pNewCTFont = CTFontCreateWithFontDescriptor( pFontDesc, fScaledFontHeight, &aMatrix ); CFDictionarySetValue( mpStyleDict, kCTFontAttributeName, pNewCTFont ); CFRelease( pNewCTFont); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits