[PATCH] fdo#50631: Fix the bounding box of rotated glyphs on MacOSX.

Jan Holesovsky kendy at suse.cz
Mon Jun 4 04:04:27 PDT 2012


Similarly to Ifb04d4a8e485182c5ef2771025b06832bfd75ae0 (commit
ac25f124858b79e302adcc533d6a658d5c529394), we need to rotate the bounding
box of glyphs on MacOSX too.

Additionally, round the position up, and convert the size more
straight-forward way.

Change-Id: Idf7a077836e65072795c6d98d61925ce62ee35b7
---
 vcl/aqua/source/gdi/salgdi.cxx |   26 +++++++++++++++++++++-----
 1 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/vcl/aqua/source/gdi/salgdi.cxx b/vcl/aqua/source/gdi/salgdi.cxx
index 0fccd6d..dbfb3e9 100644
--- a/vcl/aqua/source/gdi/salgdi.cxx
+++ b/vcl/aqua/source/gdi/salgdi.cxx
@@ -1860,11 +1860,27 @@ sal_Bool AquaSalGraphics::GetGlyphBoundRect( sal_GlyphId nGlyphId, Rectangle& rR
     if( eStatus != noErr )
         return false;
 
-    const long nMinX = (long)(+aGlyphMetrics.topLeft.x * mfFontScale - 0.5);
-    const long nMaxX = (long)(aGlyphMetrics.width * mfFontScale + 0.5) + nMinX;
-    const long nMinY = (long)(-aGlyphMetrics.topLeft.y * mfFontScale - 0.5);
-    const long nMaxY = (long)(aGlyphMetrics.height * mfFontScale + 0.5) + nMinY;
-    rRect = Rectangle( nMinX, nMinY, nMaxX, nMaxY );
+    const long nMinX = (long)(+aGlyphMetrics.topLeft.x * mfFontScale + 0.5);
+    const long nMinY = (long)(-aGlyphMetrics.topLeft.y * mfFontScale + 0.5);
+    const long nWidth  = (long)(aGlyphMetrics.width * mfFontScale + 0.5)
+    const long nHeight = (long)(aGlyphMetrics.height * mfFontScale + 0.5);
+    Rectangle aRect(Point(nMinX, nMinY), Size(nWidth, nHeight));
+
+    if ( mnATSUIRotation == 0 )
+        rRect = aRect;
+    else
+    {
+        const double fRadians = mnATSUIRotation * (M_PI/0xB40000);
+        const double nSin = sin( fRadians );
+        const double nCos = cos( fRadians );
+
+        rRect.Left() =  nCos*aRect.Left() + nSin*aRect.Top();
+        rRect.Top()  = -nSin*aRect.Left() - nCos*aRect.Top();
+
+        rRect.Right()  =  nCos*aRect.Right() + nSin*aRect.Bottom();
+        rRect.Bottom() = -nSin*aRect.Right() - nCos*aRect.Bottom();
+    }
+
     return true;
 }
 
-- 
1.7.8.3


--=-1/Y5nTkfU70xzdbkX7jZ--



More information about the LibreOffice mailing list