[Libreoffice-commits] core.git: 7 commits - include/vcl vcl/coretext vcl/inc

Khaled Hosny khaledhosny at eglug.org
Mon Jun 17 19:27:45 PDT 2013


 include/vcl/sysdata.hxx    |   10 ++--------
 vcl/coretext/ctfonts.cxx   |   42 ++++++++----------------------------------
 vcl/coretext/ctlayout.cxx  |   32 +++++++++++++-------------------
 vcl/coretext/salgdi2.cxx   |    1 -
 vcl/inc/coretext/salgdi2.h |    2 --
 5 files changed, 23 insertions(+), 64 deletions(-)

New commits:
commit a48f46cf8dfaaaa67011fab91582187dbd03de59
Author: Khaled Hosny <khaledhosny at eglug.org>
Date:   Tue Jun 18 01:55:11 2013 +0200

    Remove another pointless TODO note
    
    Change-Id: Ib4cb8643f25c8516a91a5d805a5834687d42724e

diff --git a/vcl/coretext/ctfonts.cxx b/vcl/coretext/ctfonts.cxx
index 5658276..b19dca5 100644
--- a/vcl/coretext/ctfonts.cxx
+++ b/vcl/coretext/ctfonts.cxx
@@ -130,7 +130,6 @@ void CTTextStyle::GetFontMetric( float fPixelSize, ImplFontMetricData& rMetric )
 
     // all CoreText fonts are scalable
     rMetric.mbScalableFont = true;
-    // TODO: check if any kerning is supported
     rMetric.mbKernableFont = true;
 }
 
commit a80d2a760121a1b02606d9f5f703c286aa3ba971
Author: Khaled Hosny <khaledhosny at eglug.org>
Date:   Tue Jun 18 01:48:51 2013 +0200

    Remove pointless TODO note
    
    kCTFontDisplayNameAttribute is something like Foo Regular and Foo Bold,
    we certainly don’t want that.
    
    Change-Id: Ia24a2abfcbb28883b2c3d05f66070583ddb862c9

diff --git a/vcl/coretext/ctfonts.cxx b/vcl/coretext/ctfonts.cxx
index 81feaad..5658276 100644
--- a/vcl/coretext/ctfonts.cxx
+++ b/vcl/coretext/ctfonts.cxx
@@ -318,7 +318,6 @@ ImplDevFontAttributes DevFontFromCTFontDescriptor( CTFontDescriptorRef pFD, bool
     rDFA.mbSubsettable = true;
 
     // get font name
-    // TODO: use kCTFontDisplayNameAttribute instead???
     CFStringRef pFamilyName = (CFStringRef)CTFontDescriptorCopyAttribute( pFD, kCTFontFamilyNameAttribute );
     rDFA.SetFamilyName( GetOUString( pFamilyName ) );
     // get font style
commit 984dadaf69a945c8f5e0680bca4b5830b9ebc094
Author: Khaled Hosny <khaledhosny at eglug.org>
Date:   Tue Jun 18 01:26:16 2013 +0200

    Some notes
    
    Change-Id: I665826017f03b123a8b80d6cf31e37d18e169d10

diff --git a/vcl/coretext/ctfonts.cxx b/vcl/coretext/ctfonts.cxx
index afbd8e9..81feaad 100644
--- a/vcl/coretext/ctfonts.cxx
+++ b/vcl/coretext/ctfonts.cxx
@@ -138,7 +138,8 @@ void CTTextStyle::GetFontMetric( float fPixelSize, ImplFontMetricData& rMetric )
 
 bool CTTextStyle::GetGlyphBoundRect( sal_GlyphId nGlyphId, Rectangle& rRect ) const
 {
-    CGGlyph nCGGlyph = nGlyphId & GF_IDXMASK; // NOTE: CoreText handles glyph fallback itself
+    CGGlyph nCGGlyph = nGlyphId & GF_IDXMASK;
+    // XXX: this is broken if the glyph came from fallback font
     CTFontRef aCTFontRef = (CTFontRef)CFDictionaryGetValue( mpStyleDict, kCTFontAttributeName );
 
     const CTFontOrientation aFontOrientation = kCTFontDefaultOrientation; // TODO: horz/vert
@@ -197,8 +198,8 @@ bool CTTextStyle::GetGlyphOutline( sal_GlyphId nGlyphId, basegfx::B2DPolyPolygon
 {
     rResult.clear();
 
-    // TODO: GF_FONTMASK if using non-native glyph fallback
     CGGlyph nCGGlyph = nGlyphId & GF_IDXMASK;
+    // XXX: this is broken if the glyph came from fallback font
     CTFontRef pCTFont = (CTFontRef)CFDictionaryGetValue( mpStyleDict, kCTFontAttributeName );
     CGPathRef xPath = CTFontCreatePathForGlyph( pCTFont, nCGGlyph, NULL );
 
commit fd7861397bb4e8dc5ad694a7f677e10fd271f0f6
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

diff --git a/vcl/coretext/ctfonts.cxx b/vcl/coretext/ctfonts.cxx
index 36ee281..afbd8e9 100644
--- a/vcl/coretext/ctfonts.cxx
+++ b/vcl/coretext/ctfonts.cxx
@@ -67,14 +67,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);
@@ -121,13 +113,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);
@@ -153,10 +144,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;
 }
 
@@ -219,13 +210,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 5fbcef1..0ff356f 100644
--- a/vcl/coretext/ctlayout.cxx
+++ b/vcl/coretext/ctlayout.cxx
@@ -59,11 +59,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
@@ -80,7 +75,6 @@ CTLayout::CTLayout( const CTTextStyle* pTextStyle )
 ,   mpAttrString( NULL )
 ,   mpCTLine( NULL )
 ,   mnCharCount( 0 )
-,   mfFontScale( pTextStyle->mfFontScale )
 ,   mfCachedWidth( -1 )
 ,   mnBaseAdv( 0 )
 {
@@ -149,7 +143,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 )
@@ -160,7 +154,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
@@ -189,12 +183,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 )
     {
@@ -321,7 +315,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
@@ -342,7 +336,7 @@ long CTLayout::GetTextWidth() const
         mfCachedWidth = CTLineGetTypographicBounds( mpCTLine, NULL, NULL, NULL);
     }
 
-    const long nScaledWidth = lrint( mfFontScale * mfCachedWidth );
+    const long nScaledWidth = lrint( mfCachedWidth );
     return nScaledWidth;
 }
 
@@ -392,7 +386,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;
@@ -420,11 +414,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 );
     }
 }
 
@@ -447,10 +441,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 97d1889..48f2f26 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 77ed739..158cf3c 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
commit 08e7b88d8e1c1ac0d3b30e9e664dc9bff2c7b11c
Author: Khaled Hosny <khaledhosny at eglug.org>
Date:   Tue Jun 18 00:44:51 2013 +0200

    Use Core Text defaults for kerning and ligatures
    
    Our ATSUI port did not disable kerning, so we shouldn’t disable it with
    Core Text, and ligature are enabled by default anyway.
    
    Change-Id: If3ee5fd14376c7d297c288ba6761a45ce2901a1e

diff --git a/vcl/coretext/ctfonts.cxx b/vcl/coretext/ctfonts.cxx
index 3dcfe4f..36ee281 100644
--- a/vcl/coretext/ctfonts.cxx
+++ b/vcl/coretext/ctfonts.cxx
@@ -94,15 +94,6 @@ CTTextStyle::CTTextStyle( const FontSelectPattern& rFSD )
     mpStyleDict = CFDictionaryCreateMutable( NULL, nMaxDictSize,
         &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks );
 
-    // set some default styles: no kerning, regular ligatures
-    static const CGFloat fValZero = 0.0;
-    CFNumberRef pCFFloatNumZero = CFNumberCreate( NULL, kCFNumberFloatType, &fValZero );
-    CFDictionarySetValue( mpStyleDict, kCTKernAttributeName, pCFFloatNumZero );
-    CFRelease( pCFFloatNumZero);
-    static const int nValOne = 1;
-    CFNumberRef pCFIntNumOne = CFNumberCreate( NULL, kCFNumberIntType, &nValOne );
-    CFDictionarySetValue( mpStyleDict, kCTLigatureAttributeName, pCFIntNumOne );
-    CFRelease( pCFIntNumOne);
     CFBooleanRef pCFVertBool = pReqFont->mbVertical ? kCFBooleanTrue : kCFBooleanFalse;
     CFDictionarySetValue( mpStyleDict, kCTVerticalFormsAttributeName, pCFVertBool );
 
commit a3703190c1401a15e44c455c5243d41082774330
Author: Khaled Hosny <khaledhosny at eglug.org>
Date:   Tue Jun 18 00:38:44 2013 +0200

    Reduce #ifdef #else a bit
    
    Change-Id: I888681b01e82b72ce1ed9836ddf541c543747971

diff --git a/include/vcl/sysdata.hxx b/include/vcl/sysdata.hxx
index c2953a4..57b32e3 100644
--- a/include/vcl/sysdata.hxx
+++ b/include/vcl/sysdata.hxx
@@ -216,11 +216,9 @@ struct SystemFontData
 #if defined( WNT )
     HFONT           hFont;          // native font object
 #elif defined( MACOSX )
-#ifdef ENABLE_CORETEXT
-#else
+#ifndef ENABLE_CORETEXT
     void*           aATSUFontID;    // native font object
 #endif
-#elif defined( IOS )
 #elif defined( UNX )
     void*           nFontId;        // native font id
     int             nFontFlags;     // native font flags
@@ -235,11 +233,9 @@ struct SystemFontData
 #if defined( WNT )
         , hFont( 0 )
 #elif defined( MACOSX )
-#ifdef ENABLE_CORETEXT
-#else
+#ifndef ENABLE_CORETEXT
         , aATSUFontID( NULL )
 #endif
-#elif defined( IOS )
 #elif defined( UNX )
         , nFontId( NULL )
         , nFontFlags( 0 )
commit 2e87fa36c7c0abb85d9a2bac71580ef799c9d4c8
Author: Khaled Hosny <khaledhosny at eglug.org>
Date:   Tue Jun 18 00:36:47 2013 +0200

    rCTFont is not used anywhere
    
    Change-Id: I2ee13f6a014f26ca03b34d87094af337733207e3

diff --git a/include/vcl/sysdata.hxx b/include/vcl/sysdata.hxx
index d06e72a..c2953a4 100644
--- a/include/vcl/sysdata.hxx
+++ b/include/vcl/sysdata.hxx
@@ -217,12 +217,10 @@ struct SystemFontData
     HFONT           hFont;          // native font object
 #elif defined( MACOSX )
 #ifdef ENABLE_CORETEXT
-    CTFontRef       rCTFont;        // native font object
 #else
     void*           aATSUFontID;    // native font object
 #endif
 #elif defined( IOS )
-    CTFontRef       rCTFont;        // native font object
 #elif defined( UNX )
     void*           nFontId;        // native font id
     int             nFontFlags;     // native font flags


More information about the Libreoffice-commits mailing list