[Libreoffice-commits] core.git: Branch 'libreoffice-4-1' - vcl/coretext vcl/inc

Khaled Hosny khaledhosny at eglug.org
Thu Jun 20 04:11:47 PDT 2013


 vcl/coretext/ctfonts.cxx   |   26 +++++---------------------
 vcl/coretext/ctlayout.cxx  |   32 +++++++++++++-------------------
 vcl/coretext/salgdi2.cxx   |    1 -
 vcl/inc/coretext/salgdi2.h |    2 --
 4 files changed, 18 insertions(+), 43 deletions(-)

New commits:
commit bba255bf3fd030bc62bfc033d814cdb7bd986bfd
Author: Khaled Hosny <khaledhosny at eglug.org>
Date:   Tue Jun 18 01:39:02 2013 +0200

    Remove the never set mfFontScale
    
    Lets just assume Core Text does not need this and react if a real
    problem with “huge” font sizes arise.
    
    Change-Id: I4031e7ca34692eb041ab10154df0064ab5efb462
    (cherry picked from commit fd7861397bb4e8dc5ad694a7f677e10fd271f0f6)
    Reviewed-on: https://gerrit.libreoffice.org/4383
    Reviewed-by: Noel Power <noel.power at suse.com>
    Tested-by: Noel Power <noel.power at suse.com>

diff --git a/vcl/coretext/ctfonts.cxx b/vcl/coretext/ctfonts.cxx
index 630325a..70c7399 100644
--- a/vcl/coretext/ctfonts.cxx
+++ b/vcl/coretext/ctfonts.cxx
@@ -66,14 +66,6 @@ CTTextStyle::CTTextStyle( const FontSelectPattern& rFSD )
     const FontSelectPattern* const pReqFont = &rFSD;
 
     double fScaledFontHeight = pReqFont->mfExactHeight;
-#if 0 // TODO: does CoreText need font size limiting???
-    static const float fMaxFontHeight = 144.0; // TODO: is there a limit for CoreText?
-    if( fScaledFontHeight > fMaxFontHeight )
-    {
-        mfFontScale = fScaledFontHeight / fMaxFontHeight;
-        fScaledFontHeight = fMaxFontHeight;
-    }
-#endif
 
     // convert font rotation to radian
     mfFontRotation = pReqFont->mnOrientation * (M_PI / 1800.0);
@@ -120,13 +112,12 @@ CTTextStyle::~CTTextStyle( void )
 
 // -----------------------------------------------------------------------
 
-void CTTextStyle::GetFontMetric( float fDPIY, ImplFontMetricData& rMetric ) const
+void CTTextStyle::GetFontMetric( float fPixelSize, ImplFontMetricData& rMetric ) const
 {
     // get the matching CoreText font handle
     // TODO: is it worth it to cache the CTFontRef in SetFont() and reuse it here?
     CTFontRef aCTFontRef = (CTFontRef)CFDictionaryGetValue( mpStyleDict, kCTFontAttributeName );
 
-    const double fPixelSize = (mfFontScale * fDPIY);
     rMetric.mnAscent       = lrint( CTFontGetAscent( aCTFontRef ) * fPixelSize);
     rMetric.mnDescent      = lrint( CTFontGetDescent( aCTFontRef ) * fPixelSize);
     rMetric.mnIntLeading   = lrint( CTFontGetLeading( aCTFontRef ) * fPixelSize);
@@ -152,10 +143,10 @@ bool CTTextStyle::GetGlyphBoundRect( sal_GlyphId nGlyphId, Rectangle& rRect ) co
     const CTFontOrientation aFontOrientation = kCTFontDefaultOrientation; // TODO: horz/vert
     const CGRect aCGRect = CTFontGetBoundingRectsForGlyphs( aCTFontRef, aFontOrientation, &nCGGlyph, NULL, 1 );
 
-    rRect.Left()   = lrint( mfFontScale * aCGRect.origin.x );
-    rRect.Top()    = lrint( mfFontScale * aCGRect.origin.y );
-    rRect.Right()  = lrint( mfFontScale * (aCGRect.origin.x + aCGRect.size.width) );
-    rRect.Bottom() = lrint( mfFontScale * (aCGRect.origin.y + aCGRect.size.height) );
+    rRect.Left()   = lrint( aCGRect.origin.x );
+    rRect.Top()    = lrint( aCGRect.origin.y );
+    rRect.Right()  = lrint( aCGRect.origin.x + aCGRect.size.width );
+    rRect.Bottom() = lrint( aCGRect.origin.y + aCGRect.size.height );
     return true;
 }
 
@@ -218,13 +209,6 @@ bool CTTextStyle::GetGlyphOutline( sal_GlyphId nGlyphId, basegfx::B2DPolyPolygon
     MyCGPathApplierFunc( (void*)&aGgoData, &aClosingElement );
 #endif
 
-    // apply the font scale
-    if( mfFontScale != 1.0 ) {
-        basegfx::B2DHomMatrix aScale;
-        aScale.scale( +mfFontScale, +mfFontScale );
-        rResult.transform( aScale );
-    }
-
     return true;
 }
 
diff --git a/vcl/coretext/ctlayout.cxx b/vcl/coretext/ctlayout.cxx
index 81105e2..b3542d9 100644
--- a/vcl/coretext/ctlayout.cxx
+++ b/vcl/coretext/ctlayout.cxx
@@ -58,11 +58,6 @@ private:
 
     int mnCharCount;        // ==mnEndCharPos-mnMinCharPos
 
-    // to prevent overflows
-    // font requests get size limited by downscaling huge fonts
-    // in these cases the font scale becomes something bigger than 1.0
-    float mfFontScale; // TODO: does CoreText have a font size limit?
-
     // cached details about the resulting layout
     // mutable members since these details are all lazy initialized
     mutable double  mfCachedWidth;          // cached value of resulting typographical width
@@ -79,7 +74,6 @@ CTLayout::CTLayout( const CTTextStyle* pTextStyle )
 ,   mpAttrString( NULL )
 ,   mpCTLine( NULL )
 ,   mnCharCount( 0 )
-,   mfFontScale( pTextStyle->mfFontScale )
 ,   mfCachedWidth( -1 )
 ,   mnBaseAdv( 0 )
 {
@@ -148,7 +142,7 @@ void CTLayout::AdjustLayout( ImplLayoutArgs& rArgs )
     // in RTL-layouts trailing spaces are leftmost
     // TODO: use BiDi-algorithm to thoroughly check this assumption
     if( rArgs.mnFlags & SAL_LAYOUT_BIDI_RTL)
-        mnBaseAdv = rint( CTLineGetTrailingWhitespaceWidth( mpCTLine ) * mfFontScale );
+        mnBaseAdv = rint( CTLineGetTrailingWhitespaceWidth( mpCTLine ) );
 
     // return early if there is nothing to do
     if( nPixelWidth <= 0 )
@@ -159,7 +153,7 @@ void CTLayout::AdjustLayout( ImplLayoutArgs& rArgs )
     if( (nOrigWidth >= nPixelWidth-1) && (nOrigWidth <= nPixelWidth+1) )
         return;
 
-    CTLineRef pNewCTLine = CTLineCreateJustifiedLine( mpCTLine, 1.0, nPixelWidth / mfFontScale );
+    CTLineRef pNewCTLine = CTLineCreateJustifiedLine( mpCTLine, 1.0, nPixelWidth );
     if( !pNewCTLine ) { // CTLineCreateJustifiedLine can and does fail
         // handle failure by keeping the unjustified layout
         // TODO: a better solution such as
@@ -188,12 +182,12 @@ void CTLayout::DrawText( SalGraphics& rGraphics ) const
     // so apply a temporary transformation that it flips back
     // also compensate if the font was size limited
     CGContextSaveGState( rAquaGraphics.mrContext );
-    CGContextScaleCTM( rAquaGraphics.mrContext, +mfFontScale, -mfFontScale );
+    CGContextScaleCTM( rAquaGraphics.mrContext, 1.0, -1.0 );
     CGContextSetShouldAntialias( rAquaGraphics.mrContext, !rAquaGraphics.mbNonAntialiasedText );
 
     // Draw the text
     const Point aVclPos = GetDrawPosition( Point(mnBaseAdv,0) );
-    CGPoint aTextPos = { +aVclPos.X()/mfFontScale, -aVclPos.Y()/mfFontScale };
+    CGPoint aTextPos = { (CGFloat) +aVclPos.X(), (CGFloat) -aVclPos.Y() };
 
     if( mpTextStyle->mfFontRotation != 0.0 )
     {
@@ -320,7 +314,7 @@ int CTLayout::GetNextGlyphs( int nLen, sal_GlyphId* pGlyphIDs, Point& rPos, int&
                 *(pFallbackFonts++) = pFallbackFont;
             if( !nCount++ ) {
                 const CGPoint& rCurPos = pCGGlyphPos[ nSubIndex ];
-                rPos = GetDrawPosition( Point( mfFontScale * rCurPos.x, mfFontScale * rCurPos.y) );
+                rPos = GetDrawPosition( Point( rCurPos.x, rCurPos.y) );
             }
         }
         nSubIndex = 0; // prepare for the next glyph run
@@ -341,7 +335,7 @@ long CTLayout::GetTextWidth() const
         mfCachedWidth = CTLineGetTypographicBounds( mpCTLine, NULL, NULL, NULL);
     }
 
-    const long nScaledWidth = lrint( mfFontScale * mfCachedWidth );
+    const long nScaledWidth = lrint( mfCachedWidth );
     return nScaledWidth;
 }
 
@@ -391,7 +385,7 @@ int CTLayout::GetTextBreak( long nMaxWidth, long /*nCharExtra*/, int nFactor ) c
         return STRING_LEN;
 
     CTTypesetterRef aCTTypeSetter = CTTypesetterCreateWithAttributedString( mpAttrString );
-    const double fCTMaxWidth = (double)nMaxWidth / (nFactor * mfFontScale);
+    const double fCTMaxWidth = (double)nMaxWidth / nFactor;
     CFIndex nIndex = CTTypesetterSuggestClusterBreak( aCTTypeSetter, 0, fCTMaxWidth );
     if( nIndex >= mnCharCount )
         return STRING_LEN;
@@ -419,11 +413,11 @@ void CTLayout::GetCaretPositions( int nMaxIndex, sal_Int32* pCaretXArray ) const
         (void)fPos2; // TODO: split cursor at line direction change
         // update previous trailing position
         if( n > 0 )
-            pCaretXArray[ 2*n-1 ] = lrint( fPos1 * mfFontScale );
+            pCaretXArray[ 2*n-1 ] = lrint( fPos1 );
         // update current leading position
         if( 2*n >= nMaxIndex )
             break;
-        pCaretXArray[ 2*n+0 ] = lrint( fPos1 * mfFontScale );
+        pCaretXArray[ 2*n+0 ] = lrint( fPos1 );
     }
 }
 
@@ -446,10 +440,10 @@ bool CTLayout::GetBoundRect( SalGraphics& rGraphics, Rectangle& rVCLRect ) const
     const Point aPos = GetDrawPosition( Point(mnBaseAdv, 0) );
 
     // CoreText top-bottom are vertically flipped from a VCL aspect
-    rVCLRect.Left()   = aPos.X() + mfFontScale * aMacRect.origin.x;
-    rVCLRect.Right()  = aPos.X() + mfFontScale * (aMacRect.origin.x + aMacRect.size.width);
-    rVCLRect.Bottom() = aPos.Y() - mfFontScale * aMacRect.origin.y;
-    rVCLRect.Top()    = aPos.Y() - mfFontScale * (aMacRect.origin.y + aMacRect.size.height);
+    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;
 }
 
diff --git a/vcl/coretext/salgdi2.cxx b/vcl/coretext/salgdi2.cxx
index e8c4203..5cf0f87 100644
--- a/vcl/coretext/salgdi2.cxx
+++ b/vcl/coretext/salgdi2.cxx
@@ -67,7 +67,6 @@ SystemFontList::~SystemFontList( void )
 
 ImplMacTextStyle::ImplMacTextStyle( const FontSelectPattern& rReqFont )
 :   mpFontData( (ImplMacFontData*)rReqFont.mpFontData )
-,   mfFontScale( 1.0 )
 ,   mfFontStretch( 1.0 )
 ,   mfFontRotation( 0.0 )
 {}
diff --git a/vcl/inc/coretext/salgdi2.h b/vcl/inc/coretext/salgdi2.h
index 01cf18a..532c5d7 100644
--- a/vcl/inc/coretext/salgdi2.h
+++ b/vcl/inc/coretext/salgdi2.h
@@ -108,8 +108,6 @@ public:
 
 //###protected:
     const ImplMacFontData*  mpFontData;
-    /// workaround to prevent overflows for huge font sizes
-    float               mfFontScale;
     /// <1.0: font is squeezed, >1.0 font is stretched, else 1.0
     float               mfFontStretch;
     /// text rotation in radian


More information about the Libreoffice-commits mailing list