diff options
author | Khaled Hosny <khaledhosny@eglug.org> | 2013-06-02 23:23:59 +0200 |
---|---|---|
committer | Khaled Hosny <khaledhosny@eglug.org> | 2013-06-02 23:28:30 +0200 |
commit | 01ec85b172583a204a9a2a8c9b22546e3348a8e0 (patch) | |
tree | 0c5c9a1f7bd416415fb8d2eff58049129647b837 | |
parent | b1454f3754a82a701b3d531a2b7d11bc4b4b942f (diff) |
Drop Core Text dynamic loading stufffeature/dematurize01
Our Mac OS X baseline includes Core Text.
Change-Id: Icd2f0062d172db1d4393b2dd1eac4d9f55a88495
-rw-r--r-- | vcl/coretext/ctfonts.cxx | 96 | ||||
-rw-r--r-- | vcl/coretext/ctfonts.hxx | 37 | ||||
-rw-r--r-- | vcl/coretext/ctlayout.cxx | 21 |
3 files changed, 13 insertions, 141 deletions
diff --git a/vcl/coretext/ctfonts.cxx b/vcl/coretext/ctfonts.cxx index e6cf65bd331a..2884cb5620d4 100644 --- a/vcl/coretext/ctfonts.cxx +++ b/vcl/coretext/ctfonts.cxx @@ -34,10 +34,6 @@ #include "basegfx/polygon/b2dpolygon.hxx" #include "basegfx/matrix/b2dhommatrix.hxx" -#ifndef DISABLE_CORETEXT_DYNLOAD -#include <dlfcn.h> -#endif - // ======================================================================= // CoreText specific physically available font face @@ -176,12 +172,11 @@ void CTTextStyle::GetFontMetric( float fDPIY, ImplFontMetricData& rMetric ) cons bool CTTextStyle::GetGlyphBoundRect( sal_GlyphId nGlyphId, Rectangle& rRect ) const { - const DynCoreTextSyms& rCT = DynCoreTextSyms::get(); CGGlyph nCGGlyph = nGlyphId & GF_IDXMASK; // NOTE: CoreText handles glyph fallback itself CTFontRef aCTFontRef = (CTFontRef)CFDictionaryGetValue( mpStyleDict, kCTFontAttributeName ); const CTFontOrientation aFontOrientation = kCTFontDefaultOrientation; // TODO: horz/vert - const CGRect aCGRect = rCT.FontGetBoundingRectsForGlyphs( aCTFontRef, aFontOrientation, &nCGGlyph, NULL, 1 ); + const CGRect aCGRect = CTFontGetBoundingRectsForGlyphs( aCTFontRef, aFontOrientation, &nCGGlyph, NULL, 1 ); rRect.Left() = lrint( mfFontScale * aCGRect.origin.x ); rRect.Top() = lrint( mfFontScale * aCGRect.origin.y ); @@ -236,11 +231,10 @@ bool CTTextStyle::GetGlyphOutline( sal_GlyphId nGlyphId, basegfx::B2DPolyPolygon { rResult.clear(); - const DynCoreTextSyms& rCT = DynCoreTextSyms::get(); // TODO: GF_FONTMASK if using non-native glyph fallback CGGlyph nCGGlyph = nGlyphId & GF_IDXMASK; CTFontRef pCTFont = (CTFontRef)CFDictionaryGetValue( mpStyleDict, kCTFontAttributeName ); - CGPathRef xPath = rCT.FontCreatePathForGlyph( pCTFont, nCGGlyph, NULL ); + CGPathRef xPath = CTFontCreatePathForGlyph( pCTFont, nCGGlyph, NULL ); GgoData aGgoData; aGgoData.mpPolyPoly = &rResult; @@ -490,22 +484,15 @@ ImplMacFontData* CTFontList::GetFontDataFromId( sal_IntPtr nFontId ) const bool CTFontList::Init( void ) { -#ifndef DISABLE_CORETEXT_DYNLOAD - // check availability of the CoreText API - const DynCoreTextSyms& rCT = DynCoreTextSyms::get(); - if( !rCT.IsActive() ) - return false; -#endif // DISABLE_CORETEXT_DYNLOAD - // enumerate available system fonts static const int nMaxDictEntries = 8; CFMutableDictionaryRef pCFDict = CFDictionaryCreateMutable( NULL, nMaxDictEntries, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks ); CFDictionaryAddValue( pCFDict, kCTFontCollectionRemoveDuplicatesOption, kCFBooleanTrue ); - mpCTFontCollection = rCT.FontCollectionCreateFromAvailableFonts( pCFDict ); + mpCTFontCollection = CTFontCollectionCreateFromAvailableFonts( pCFDict ); CFRelease( pCFDict ); - mpCTFontArray = rCT.FontCollectionCreateMatchingFontDescriptors( mpCTFontCollection ); + mpCTFontArray = CTFontCollectionCreateMatchingFontDescriptors( mpCTFontCollection ); const int nFontCount = CFArrayGetCount( mpCTFontArray ); const CFRange aFullRange = CFRangeMake( 0, nFontCount ); CFArrayApplyFunction( mpCTFontArray, aFullRange, CTFontEnumCallBack, this ); @@ -515,81 +502,6 @@ bool CTFontList::Init( void ) // ======================================================================= -#ifndef DISABLE_CORETEXT_DYNLOAD - -DynCoreTextSyms::DynCoreTextSyms( void ) -{ - mbIsActive = false; - - // check if CoreText has been explicitely disabled - const char* pEnvStr = getenv( "SAL_DISABLE_CORETEXT"); - if( pEnvStr && (pEnvStr[0] != '0') ) - return; - - // check CoreText version - GetCoreTextVersion = (uint32_t(*)(void))dlsym( RTLD_DEFAULT, "CTGetCoreTextVersion"); - if( !GetCoreTextVersion) return; - - const uint32_t nCTVersion = GetCoreTextVersion(); - static const uint32_t mykCTVersionNumber10_5 = 0x00020000; - if( nCTVersion < mykCTVersionNumber10_5) - return; - - // load CoreText symbols dynamically - LineGetTrailingWhitespaceWidth = (double(*)(CTLineRef))dlsym( RTLD_DEFAULT, "CTLineGetTrailingWhitespaceWidth"); - if( !LineGetTrailingWhitespaceWidth) return; - - LineCreateJustifiedLine = (CTLineRef(*)(CTLineRef,CGFloat,double))dlsym( RTLD_DEFAULT, "CTLineCreateJustifiedLine"); - if( !LineCreateJustifiedLine) return; - - LineGetOffsetForStringIndex = (CGFloat(*)(CTLineRef,CFIndex,CGFloat*))dlsym( RTLD_DEFAULT, "CTLineGetOffsetForStringIndex"); - if( !LineGetOffsetForStringIndex) return; - - LineGetGlyphRuns = (CFArrayRef(*)(CTLineRef))dlsym( RTLD_DEFAULT, "CTLineGetGlyphRuns"); - if( !LineGetGlyphRuns) return; - - RunGetGlyphCount = (CFIndex(*)(CTRunRef))dlsym( RTLD_DEFAULT, "CTRunGetGlyphCount"); - if( !RunGetGlyphCount) return; - - RunGetGlyphsPtr = (const CGGlyph*(*)(CTRunRef))dlsym( RTLD_DEFAULT, "CTRunGetGlyphsPtr"); - if( !RunGetGlyphsPtr) return; - - RunGetPositionsPtr = (const CGPoint*(*)(CTRunRef))dlsym( RTLD_DEFAULT, "CTRunGetPositionsPtr"); - if( !RunGetPositionsPtr) return; - - RunGetAdvancesPtr = (const CGSize*(*)(CTRunRef))dlsym( RTLD_DEFAULT, "CTRunGetAdvancesPtr"); - if( !RunGetAdvancesPtr) return; - - RunGetStringIndicesPtr = (const CFIndex*(*)(CTRunRef))dlsym( RTLD_DEFAULT, "CTRunGetStringIndicesPtr"); - if( !RunGetStringIndicesPtr) return; - - FontCollectionCreateFromAvailableFonts = (CTFontCollectionRef(*)(CFDictionaryRef))dlsym( RTLD_DEFAULT, "CTFontCollectionCreateFromAvailableFonts"); - if( !FontCollectionCreateFromAvailableFonts) return; - - FontCollectionCreateMatchingFontDescriptors = (CFArrayRef(*)(CTFontCollectionRef))dlsym( RTLD_DEFAULT, "CTFontCollectionCreateMatchingFontDescriptors"); - if( !FontCollectionCreateMatchingFontDescriptors) return; - - FontCreatePathForGlyph = (CGPathRef(*)(CTFontRef,CGGlyph,const CGAffineTransform*))dlsym( RTLD_DEFAULT, "CTFontCreatePathForGlyph"); - if( !FontCreatePathForGlyph) return; - - FontGetBoundingRectsForGlyphs = (CGRect(*)(CTFontRef,CTFontOrientation,CGGlyph*,CGRect*,CFIndex))dlsym( RTLD_DEFAULT, "CTFontGetBoundingRectsForGlyphs"); - if( !FontGetBoundingRectsForGlyphs) return; - - mbIsActive = true; -} - -// ----------------------------------------------------------------------- - -const DynCoreTextSyms& DynCoreTextSyms::get( void ) -{ - static DynCoreTextSyms aCT; - return aCT; -} - -#endif // DISABLE_CORETEXT_DYNLOAD - -// ======================================================================= - SystemFontList* GetCoretextFontList( void ) { CTFontList* pList = new CTFontList(); diff --git a/vcl/coretext/ctfonts.hxx b/vcl/coretext/ctfonts.hxx index ec2e6e7a9f43..e903b639816c 100644 --- a/vcl/coretext/ctfonts.hxx +++ b/vcl/coretext/ctfonts.hxx @@ -51,40 +51,3 @@ private: // ======================================================================= -#ifndef DISABLE_CORETEXT_DYNLOAD -// the CoreText symbols may need to be loaded dynamically -// since platform targets like OSX 10.4 do not provide all required symbols -// TODO: avoid the dlsym stuff if the target platform is >= OSX10.5 - -class DynCoreTextSyms -{ -public: - // dynamic symbols to access the CoreText API - uint32_t (*GetCoreTextVersion)(void); - CTFontCollectionRef (*FontCollectionCreateFromAvailableFonts)(CFDictionaryRef); - CFArrayRef (*FontCollectionCreateMatchingFontDescriptors)(CTFontCollectionRef); - CGPathRef (*FontCreatePathForGlyph)(CTFontRef,CGGlyph,const CGAffineTransform*); - CGRect (*FontGetBoundingRectsForGlyphs)(CTFontRef,CTFontOrientation,CGGlyph*,CGRect*,CFIndex); - CTLineRef (*LineCreateJustifiedLine)(CTLineRef,CGFloat,double); - double (*LineGetTrailingWhitespaceWidth)(CTLineRef); - CGFloat (*LineGetOffsetForStringIndex)(CTLineRef,CFIndex,CGFloat*); - CFArrayRef (*LineGetGlyphRuns)(CTLineRef); - CFIndex (*RunGetGlyphCount)(CTRunRef); - const CGGlyph* (*RunGetGlyphsPtr)(CTRunRef); - const CGPoint* (*RunGetPositionsPtr)(CTRunRef); - const CGSize* (*RunGetAdvancesPtr)(CTRunRef); - const CFIndex * (*RunGetStringIndicesPtr)(CTRunRef); - - // singleton helpers - static const DynCoreTextSyms& get( void ); - bool IsActive( void ) const { return mbIsActive; } - -private: - explicit DynCoreTextSyms( void ); - bool mbIsActive; -}; - -#endif // DISABLE_CORETEXT_DYNLOAD - -// ======================================================================= - diff --git a/vcl/coretext/ctlayout.cxx b/vcl/coretext/ctlayout.cxx index 30da812c88fc..0d710470ffb6 100644 --- a/vcl/coretext/ctlayout.cxx +++ b/vcl/coretext/ctlayout.cxx @@ -145,10 +145,9 @@ void CTLayout::AdjustLayout( ImplLayoutArgs& rArgs ) if( !mpCTLine) return; - const DynCoreTextSyms& rCT = DynCoreTextSyms::get(); // CoreText fills trailing space during justification so we have to // take that into account when requesting CT to justify something - mfTrailingSpaceWidth = rCT.LineGetTrailingWhitespaceWidth( mpCTLine ); + mfTrailingSpaceWidth = CTLineGetTrailingWhitespaceWidth( mpCTLine ); const int nTrailingSpaceWidth = rint( mfFontScale * mfTrailingSpaceWidth ); int nOrigWidth = GetTextWidth(); @@ -181,7 +180,7 @@ void CTLayout::AdjustLayout( ImplLayoutArgs& rArgs ) if( (nOrigWidth >= nPixelWidth-1) && (nOrigWidth <= nPixelWidth+1) ) return; - CTLineRef pNewCTLine = rCT.LineCreateJustifiedLine( mpCTLine, 1.0, nPixelWidth / mfFontScale ); + CTLineRef pNewCTLine = CTLineCreateJustifiedLine( mpCTLine, 1.0, nPixelWidth / mfFontScale ); if( !pNewCTLine ) { // CTLineCreateJustifiedLine can and does fail // handle failure by keeping the unjustified layout // TODO: a better solution such as @@ -258,7 +257,6 @@ int CTLayout::GetNextGlyphs( int nLen, sal_GlyphId* pGlyphIDs, Point& rPos, int& int nCount = 0; int nSubIndex = nStart; - const DynCoreTextSyms& rCT = DynCoreTextSyms::get(); typedef std::vector<CGGlyph> CGGlyphVector; typedef std::vector<CGPoint> CGPointVector; typedef std::vector<CGSize> CGSizeVector; @@ -269,11 +267,11 @@ int CTLayout::GetNextGlyphs( int nLen, sal_GlyphId* pGlyphIDs, Point& rPos, int& CFIndexVector aCFIndexVec; // TODO: iterate over cached layout - CFArrayRef aGlyphRuns = rCT.LineGetGlyphRuns( mpCTLine ); + CFArrayRef aGlyphRuns = CTLineGetGlyphRuns( mpCTLine ); const int nRunCount = CFArrayGetCount( aGlyphRuns ); for( int nRunIndex = 0; nRunIndex < nRunCount; ++nRunIndex ) { CTRunRef pGlyphRun = (CTRunRef)CFArrayGetValueAtIndex( aGlyphRuns, nRunIndex ); - const CFIndex nGlyphsInRun = rCT.RunGetGlyphCount( pGlyphRun ); + const CFIndex nGlyphsInRun = CTRunGetGlyphCount( pGlyphRun ); // skip to the first glyph run of interest if( nSubIndex >= nGlyphsInRun ) { nSubIndex -= nGlyphsInRun; @@ -282,13 +280,13 @@ int CTLayout::GetNextGlyphs( int nLen, sal_GlyphId* pGlyphIDs, Point& rPos, int& const CFRange aFullRange = CFRangeMake( 0, nGlyphsInRun ); // get glyph run details - const CGGlyph* pCGGlyphIdx = rCT.RunGetGlyphsPtr( pGlyphRun ); + const CGGlyph* pCGGlyphIdx = CTRunGetGlyphsPtr( pGlyphRun ); if( !pCGGlyphIdx ) { aCGGlyphVec.reserve( nGlyphsInRun ); CTRunGetGlyphs( pGlyphRun, aFullRange, &aCGGlyphVec[0] ); pCGGlyphIdx = &aCGGlyphVec[0]; } - const CGPoint* pCGGlyphPos = rCT.RunGetPositionsPtr( pGlyphRun ); + const CGPoint* pCGGlyphPos = CTRunGetPositionsPtr( pGlyphRun ); if( !pCGGlyphPos ) { aCGPointVec.reserve( nGlyphsInRun ); CTRunGetPositions( pGlyphRun, aFullRange, &aCGPointVec[0] ); @@ -297,7 +295,7 @@ int CTLayout::GetNextGlyphs( int nLen, sal_GlyphId* pGlyphIDs, Point& rPos, int& const CGSize* pCGGlyphAdvs = NULL; if( pGlyphAdvances) { - pCGGlyphAdvs = rCT.RunGetAdvancesPtr( pGlyphRun ); + pCGGlyphAdvs = CTRunGetAdvancesPtr( pGlyphRun ); if( !pCGGlyphAdvs) { aCGSizeVec.reserve( nGlyphsInRun ); CTRunGetAdvances( pGlyphRun, aFullRange, &aCGSizeVec[0] ); @@ -307,7 +305,7 @@ int CTLayout::GetNextGlyphs( int nLen, sal_GlyphId* pGlyphIDs, Point& rPos, int& const CFIndex* pCGGlyphStrIdx = NULL; if( pCharIndexes) { - pCGGlyphStrIdx = rCT.RunGetStringIndicesPtr( pGlyphRun ); + pCGGlyphStrIdx = CTRunGetStringIndicesPtr( pGlyphRun ); if( !pCGGlyphStrIdx) { aCFIndexVec.reserve( nGlyphsInRun ); CTRunGetStringIndices( pGlyphRun, aFullRange, &aCFIndexVec[0] ); @@ -422,12 +420,11 @@ void CTLayout::GetCaretPositions( int nMaxIndex, sal_Int32* pCaretXArray ) const for( int i = 0; i < nMaxIndex; ++i ) pCaretXArray[ i ] = -1; - const DynCoreTextSyms& rCT = DynCoreTextSyms::get(); for( int n = 0; n <= mnCharCount; ++n ) { // measure the characters cursor position CGFloat fPos2 = -1; - const CGFloat fPos1 = rCT.LineGetOffsetForStringIndex( mpCTLine, n, &fPos2 ); + const CGFloat fPos1 = CTLineGetOffsetForStringIndex( mpCTLine, n, &fPos2 ); (void)fPos2; // TODO: split cursor at line direction change // update previous trailing position if( n > 0 ) |