[Libreoffice-commits] core.git: 2 commits - vcl/coretext

Khaled Hosny khaledhosny at eglug.org
Mon Jun 3 14:59:05 PDT 2013


 vcl/coretext/salgdi2.cxx |   87 +++++++++--------------------------------------
 1 file changed, 17 insertions(+), 70 deletions(-)

New commits:
commit 5e33f1c09b5dcfaa9cabdf1711c9a173514a1c7b
Author: Khaled Hosny <khaledhosny at eglug.org>
Date:   Mon Jun 3 23:55:58 2013 +0200

    Use Core Text font manager instead of deprecated ATS
    
    Change-Id: I660a895a227da3d28a0b410c56f2395961a5bc4f

diff --git a/vcl/coretext/salgdi2.cxx b/vcl/coretext/salgdi2.cxx
index c543912..2f7da5b 100644
--- a/vcl/coretext/salgdi2.cxx
+++ b/vcl/coretext/salgdi2.cxx
@@ -54,11 +54,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 )
@@ -377,22 +372,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;
 }
@@ -454,26 +444,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;
 }
 
commit 06fe77331d1ad8eb2e5a158bb1cb083daaf1f910
Author: Khaled Hosny <khaledhosny at eglug.org>
Date:   Mon Jun 3 23:01:56 2013 +0200

    Drop ENABLE_CORETEXT
    
    This file is Core Text only already.
    
    Change-Id: Ic4c1f44296eaae582091e515d3ca1b4aa227301e

diff --git a/vcl/coretext/salgdi2.cxx b/vcl/coretext/salgdi2.cxx
index 74c906f..c543912 100644
--- a/vcl/coretext/salgdi2.cxx
+++ b/vcl/coretext/salgdi2.cxx
@@ -38,11 +38,7 @@
 
 #include "coretext/salgdi2.h"
 #include "aqua/salframe.h"
-#ifdef ENABLE_CORETEXT
 #include "ctfonts.hxx"
-#else
-#include "atsfonts.hxx"
-#endif
 
 #include "fontsubset.hxx"
 #include "impfont.hxx"
@@ -436,15 +432,9 @@ void AquaSalGraphics::GetDevFontList( ImplDevFontList* pFontList )
     // through it as should be all event handlers
 
     SalData* pSalData = GetSalData();
-#ifdef ENABLE_CORETEXT
     SystemFontList* GetCoretextFontList(void); // forward declaration
     if( !pSalData->mpFontList )
         pSalData->mpFontList = GetCoretextFontList();
-#else
-    SystemFontList* GetAtsFontList(void);      // forward declaration
-    if( !pSalData->mpFontList )
-        pSalData->mpFontList = GetAtsFontList();
-#endif
 
     // Copy all PhysicalFontFace objects contained in the SystemFontList
     pSalData->mpFontList->AnnounceFonts( *pFontList );
@@ -870,33 +860,6 @@ SystemFontData AquaSalGraphics::GetSysFontData( int /* nFallbacklevel */ ) const
     SystemFontData aSysFontData;
     aSysFontData.nSize = sizeof( SystemFontData );
 
-#ifndef ENABLE_CORETEXT
-    // NOTE: Native ATSU font fallbacks are used, not the VCL fallbacks.
-    ATSUFontID fontId;
-    OSStatus err;
-    err = ATSUGetAttribute( maATSUStyle, kATSUFontTag, sizeof(fontId), &fontId, 0 );
-    if (err) fontId = 0;
-    aSysFontData.aATSUFontID = (void *) fontId;
-
-    Boolean bFbold;
-    err = ATSUGetAttribute( maATSUStyle, kATSUQDBoldfaceTag, sizeof(bFbold), &bFbold, 0 );
-    if (err) bFbold = FALSE;
-    aSysFontData.bFakeBold = (bool) bFbold;
-
-    Boolean bFItalic;
-    err = ATSUGetAttribute( maATSUStyle, kATSUQDItalicTag, sizeof(bFItalic), &bFItalic, 0 );
-    if (err) bFItalic = FALSE;
-    aSysFontData.bFakeItalic = (bool) bFItalic;
-
-    ATSUVerticalCharacterType aVerticalCharacterType;
-    err = ATSUGetAttribute( maATSUStyle, kATSUVerticalCharacterTag, sizeof(aVerticalCharacterType), &aVerticalCharacterType, 0 );
-    if (!err && aVerticalCharacterType == kATSUStronglyVertical) {
-        aSysFontData.bVerticalCharacterType = true;
-    } else {
-        aSysFontData.bVerticalCharacterType = false;
-    }
-#endif
-
     aSysFontData.bAntialias = !mbNonAntialiasedText;
 
     return aSysFontData;


More information about the Libreoffice-commits mailing list