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

Caolán McNamara caolanm at redhat.com
Tue Aug 27 08:54:01 PDT 2013


 vcl/coretext/salgdi2.cxx |   56 +++++++++++++++++++++++------------------------
 1 file changed, 28 insertions(+), 28 deletions(-)

New commits:
commit 31fbd9d8b65c7eb9ad618fd68f331a32760c468e
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Aug 27 16:40:53 2013 +0100

    Related: fdo#68192 register bundled fonts
    
    We have to register them one at a time, like windows, this means we detect our
    bundled opensymbol which makes the "format->bullets and numbering" preview work
    again.
    
    Doesn't however fix fdo#68192 yet, more magic smoke required.
    
    (cherry picked from commit 8efbafaf8681d39c8c3674368e02ddd572ba5d32)
    
    Conflicts:
    	vcl/coretext/salgdi2.cxx
    
    Change-Id: I430c91b48d96fb8d62e3b073898b72cf2b8ddea6
    Reviewed-on: https://gerrit.libreoffice.org/5647
    Reviewed-by: Thorsten Behrens <tbehrens at suse.com>
    Tested-by: Thorsten Behrens <tbehrens at suse.com>

diff --git a/vcl/coretext/salgdi2.cxx b/vcl/coretext/salgdi2.cxx
index 5cf0f87..ed6dd90 100644
--- a/vcl/coretext/salgdi2.cxx
+++ b/vcl/coretext/salgdi2.cxx
@@ -346,9 +346,13 @@ sal_uLong AquaSalGraphics::GetKernPairs( sal_uLong, ImplKernPairData* )
 
 // -----------------------------------------------------------------------
 
-static bool AddTempFontDir( const char* pDir )
+static bool AddTempDevFont(const OUString& rFontFileURL)
 {
-    CFStringRef rDir = CFStringCreateWithCString(NULL, pDir, kCFStringEncodingUTF8);
+    OUString aUSytemPath;
+    OSL_VERIFY( !osl::FileBase::getSystemPathFromFileURL( rFontFileURL, aUSytemPath ) );
+    OString aCFileName = OUStringToOString( aUSytemPath, RTL_TEXTENCODING_UTF8 );
+
+    CFStringRef rDir = CFStringCreateWithCString(NULL, aCFileName.getStr(), kCFStringEncodingUTF8);
     CFURLRef rDirURL = CFURLCreateWithFileSystemPath(NULL, rDir, kCFURLPOSIXPathStyle, true);
 
     CFErrorRef error;
@@ -363,24 +367,36 @@ static bool AddTempFontDir( const char* pDir )
     return true;
 }
 
-static bool AddLocalTempFontDirs( void )
+static void AddTempFontDir( const OUString &rFontDirUrl )
+{
+    osl::Directory aFontDir( rFontDirUrl );
+    osl::FileBase::RC rcOSL = aFontDir.open();
+    if( rcOSL == osl::FileBase::E_None )
+    {
+        osl::DirectoryItem aDirItem;
+
+        while( aFontDir.getNextItem( aDirItem, 10 ) == osl::FileBase::E_None )
+        {
+            osl::FileStatus aFileStatus( osl_FileStatus_Mask_FileURL );
+            rcOSL = aDirItem.getFileStatus( aFileStatus );
+            if ( rcOSL == osl::FileBase::E_None )
+                AddTempDevFont(aFileStatus.getFileURL());
+        }
+    }
+}
+
+static void AddLocalTempFontDirs()
 {
     static bool bFirst = true;
     if( !bFirst )
-        return false;
+        return;
     bFirst = false;
 
     // add private font files
 
     OUString aBrandStr( "$BRAND_BASE_DIR" );
     rtl_bootstrap_expandMacros( &aBrandStr.pData );
-    OUString aBrandSysPath;
-    OSL_VERIFY( osl_getSystemPathFromFileURL( aBrandStr.pData, &aBrandSysPath.pData ) == osl_File_E_None );
-
-    OStringBuffer aBrandFontDir( aBrandSysPath.getLength()*2 );
-    aBrandFontDir.append( OUStringToOString( aBrandSysPath, RTL_TEXTENCODING_UTF8 ) );
-    aBrandFontDir.append( "/share/fonts/truetype/" );
-    return AddTempFontDir( aBrandFontDir.getStr() );
+    AddTempFontDir( aBrandStr + "/share/fonts/truetype/" );
 }
 
 void AquaSalGraphics::GetDevFontList( ImplDevFontList* pFontList )
@@ -417,23 +433,7 @@ void AquaSalGraphics::ClearDevFontCache()
 bool AquaSalGraphics::AddTempDevFont( ImplDevFontList*,
     const OUString& rFontFileURL, const OUString& /*rFontName*/ )
 {
-    OUString aUSytemPath;
-    OSL_VERIFY( !osl::FileBase::getSystemPathFromFileURL( rFontFileURL, aUSytemPath ) );
-    OString aCFileName = OUStringToOString( aUSytemPath, RTL_TEXTENCODING_UTF8 );
-
-    CFStringRef rDir = CFStringCreateWithCString(NULL, aCFileName.getStr(), kCFStringEncodingUTF8);
-    CFURLRef rDirURL = CFURLCreateWithFileSystemPath(NULL, rDir, kCFURLPOSIXPathStyle, true);
-
-    CFErrorRef error;
-    bool success = CTFontManagerRegisterFontsForURL(rDirURL, kCTFontManagerScopeProcess, &error);
-
-    if (!success)
-    {
-        CFRelease(error);
-        return false;
-    }
-
-    return true;
+    return ::AddTempDevFont(rFontFileURL);
 }
 
 // -----------------------------------------------------------------------


More information about the Libreoffice-commits mailing list