diff options
author | Khaled Hosny <khaledhosny@eglug.org> | 2013-06-03 23:55:58 +0200 |
---|---|---|
committer | Khaled Hosny <khaledhosny@eglug.org> | 2013-06-04 00:01:14 +0200 |
commit | b0dc4032e746575cc3a66155782a57774890e94d (patch) | |
tree | 81ad2641bf1fb9aa89968dd83eec8492dc5f0614 /vcl | |
parent | dfcad766ad3937c5dc435fc10b1387b2c941790e (diff) |
Use Core Text font manager instead of deprecated ATS
Change-Id: I660a895a227da3d28a0b410c56f2395961a5bc4f
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/coretext/salgdi2.cxx | 50 |
1 files changed, 17 insertions, 33 deletions
diff --git a/vcl/coretext/salgdi2.cxx b/vcl/coretext/salgdi2.cxx index 74c906f52f3b..ba076a7cc74b 100644 --- a/vcl/coretext/salgdi2.cxx +++ b/vcl/coretext/salgdi2.cxx @@ -58,11 +58,6 @@ SystemFontList::~SystemFontList( void ) {} -// ATSUI is deprecated in 10.6 (or already 10.5?) -#if HAVE_GCC_PRAGMA_DIAGNOSTIC_MODIFY -#pragma GCC diagnostic warning "-Wdeprecated-declarations" -#endif - // ======================================================================= ImplMacTextStyle::ImplMacTextStyle( const FontSelectPattern& rReqFont ) @@ -381,22 +376,17 @@ sal_uLong AquaSalGraphics::GetKernPairs( sal_uLong, ImplKernPairData* ) static bool AddTempFontDir( const char* pDir ) { - FSRef aPathFSRef; - Boolean bIsDirectory = true; - OSStatus eStatus = FSPathMakeRef( reinterpret_cast<const UInt8*>(pDir), &aPathFSRef, &bIsDirectory ); - DBG_ASSERTWARNING( (eStatus==noErr) && bIsDirectory, "vcl AddTempFontDir() with invalid directory name!" ); - if( eStatus != noErr ) - return false; + CFStringRef rDir = CFStringCreateWithCString(NULL, pDir, kCFStringEncodingUTF8); + CFURLRef rDirURL = CFURLCreateWithFileSystemPath(NULL, rDir, kCFURLPOSIXPathStyle, true); - // TODO: deactivate ATSFontContainerRef when closing app - ATSFontContainerRef aATSFontContainer; + CFErrorRef error; + bool success = CTFontManagerRegisterFontsForURL(rDirURL, kCTFontManagerScopeProcess, &error); - const ATSFontContext eContext = kATSFontContextLocal; // TODO: *Global??? - eStatus = ::ATSFontActivateFromFileReference( &aPathFSRef, - eContext, kATSFontFormatUnspecified, NULL, kATSOptionFlagsDefault, - &aATSFontContainer ); - if( eStatus != noErr ) + if (!success) + { + CFRelease(error); return false; + } return true; } @@ -464,26 +454,20 @@ bool AquaSalGraphics::AddTempDevFont( ImplDevFontList*, { OUString aUSytemPath; OSL_VERIFY( !osl::FileBase::getSystemPathFromFileURL( rFontFileURL, aUSytemPath ) ); - - FSRef aNewRef; - Boolean bIsDirectory = true; OString aCFileName = OUStringToOString( aUSytemPath, RTL_TEXTENCODING_UTF8 ); - OSStatus eStatus = FSPathMakeRef( (UInt8*)aCFileName.getStr(), &aNewRef, &bIsDirectory ); - DBG_ASSERT( (eStatus==noErr) && !bIsDirectory, "vcl AddTempDevFont() with invalid fontfile name!" ); - if( eStatus != noErr ) - return false; - ATSFontContainerRef oContainer; + CFStringRef rDir = CFStringCreateWithCString(NULL, aCFileName.getStr(), kCFStringEncodingUTF8); + CFURLRef rDirURL = CFURLCreateWithFileSystemPath(NULL, rDir, kCFURLPOSIXPathStyle, true); + + CFErrorRef error; + bool success = CTFontManagerRegisterFontsForURL(rDirURL, kCTFontManagerScopeProcess, &error); - const ATSFontContext eContext = kATSFontContextLocal; // TODO: *Global??? - eStatus = ::ATSFontActivateFromFileReference( &aNewRef, - eContext, kATSFontFormatUnspecified, NULL, kATSOptionFlagsDefault, - &oContainer ); - if( eStatus != noErr ) + if (!success) + { + CFRelease(error); return false; + } - // TODO: ATSFontDeactivate( oContainer ) when fonts are no longer needed - // TODO: register new ImplMacFontdata in pFontList return true; } |