diff options
author | Tor Lillqvist <tml@iki.fi> | 2013-06-19 15:12:30 +0300 |
---|---|---|
committer | Noel Power <noel.power@suse.com> | 2013-06-20 11:19:52 +0000 |
commit | 8d55b1b6ffd2de965ae3db0712fb2317a9310f1f (patch) | |
tree | 4e48ccfadb12ef92bfcb37d46cfbe658e2db4178 | |
parent | 083baaa6d8adb04617035ef23a1c42f8e8903c50 (diff) |
fdo#63616: Fix GetBoundRect for rotated text in CoreText backend
Change-Id: I8c9ee84afd71481c2c6b002265b86e048f369f5c
(cherry picked from commit b9c46f46cebc0ebed5a91f8fbb9d0a01366f1f77)
Reviewed-on: https://gerrit.libreoffice.org/4388
Reviewed-by: Noel Power <noel.power@suse.com>
Tested-by: Noel Power <noel.power@suse.com>
-rw-r--r-- | vcl/coretext/ctlayout.cxx | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/vcl/coretext/ctlayout.cxx b/vcl/coretext/ctlayout.cxx index cbd7e918851b..8c99ca1dcbd8 100644 --- a/vcl/coretext/ctlayout.cxx +++ b/vcl/coretext/ctlayout.cxx @@ -432,18 +432,39 @@ bool CTLayout::GetBoundRect( SalGraphics& rGraphics, Rectangle& rVCLRect ) const return false; #endif + CGContextSaveGState( rAquaGraphics.mrContext ); + CGContextScaleCTM( rAquaGraphics.mrContext, 1.0, -1.0 ); + CGContextSetShouldAntialias( rAquaGraphics.mrContext, !rAquaGraphics.mbNonAntialiasedText ); + + const Point aVclPos = GetDrawPosition( Point(mnBaseAdv,0) ); + CGPoint aTextPos = { (CGFloat) +aVclPos.X(), (CGFloat) -aVclPos.Y() }; + + if( mpTextStyle->mfFontRotation != 0.0 ) + { + const CGFloat fRadians = mpTextStyle->mfFontRotation; + CGContextRotateCTM( rAquaGraphics.mrContext, +fRadians ); + + const CGAffineTransform aInvMatrix = CGAffineTransformMakeRotation( -fRadians ); + aTextPos = CGPointApplyAffineTransform( aTextPos, aInvMatrix ); + } + + CGContextSetTextPosition( rAquaGraphics.mrContext, aTextPos.x, aTextPos.y ); CGRect aMacRect = CTLineGetImageBounds( mpCTLine, rAquaGraphics.mrContext ); - CGPoint aMacPos = CGContextGetTextPosition( rAquaGraphics.mrContext ); - aMacRect.origin.x -= aMacPos.x; - aMacRect.origin.y -= aMacPos.y; - const Point aPos = GetDrawPosition( Point(mnBaseAdv, 0) ); + if( mpTextStyle->mfFontRotation != 0.0 ) + { + const CGFloat fRadians = mpTextStyle->mfFontRotation; + const CGAffineTransform aMatrix = CGAffineTransformMakeRotation( +fRadians ); + aMacRect = CGRectApplyAffineTransform( aMacRect, aMatrix ); + } + + CGContextRestoreGState( rAquaGraphics.mrContext ); + + rVCLRect.Left() = aVclPos.X() + aMacRect.origin.x; + rVCLRect.Right() = aVclPos.X() + (aMacRect.origin.x + aMacRect.size.width); + rVCLRect.Bottom() = aVclPos.Y() - (aMacRect.origin.y); + rVCLRect.Top() = aVclPos.Y() - (aMacRect.origin.y + aMacRect.size.height); - // CoreText top-bottom are vertically flipped from a VCL aspect - rVCLRect.Left() = aPos.X() + aMacRect.origin.x; - rVCLRect.Right() = aPos.X() + (aMacRect.origin.x + aMacRect.size.width); - rVCLRect.Bottom() = aPos.Y() - aMacRect.origin.y; - rVCLRect.Top() = aPos.Y() - (aMacRect.origin.y + aMacRect.size.height); return true; } |