[Libreoffice-commits] core.git: vcl/inc vcl/quartz

Douglas Mencken dougmencken at gmail.com
Sun Feb 23 11:05:44 PST 2014


 vcl/inc/quartz/salgdi.h |    9 +++++++++
 vcl/quartz/ctfonts.cxx  |    8 +++++++-
 vcl/quartz/salgdi.cxx   |   24 ++++++++++++++++++++----
 3 files changed, 36 insertions(+), 5 deletions(-)

New commits:
commit ae4a8c6152a6234eed52482da64d84ad5a56c03d
Author: Douglas Mencken <dougmencken at gmail.com>
Date:   Sat Feb 22 14:24:45 2014 -0500

    CoreText SDK 10.5 compatibility
    
    Change-Id: Ic876ec473b1c03a70c160af4251c68b299b27eca
    Reviewed-on: https://gerrit.libreoffice.org/7143
    Reviewed-by: Norbert Thiebaud <nthiebaud at gmail.com>
    Tested-by: Norbert Thiebaud <nthiebaud at gmail.com>

diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h
index 7cd2e83..a6c8a8c 100644
--- a/vcl/inc/quartz/salgdi.h
+++ b/vcl/inc/quartz/salgdi.h
@@ -29,6 +29,15 @@
 #include <ApplicationServices/ApplicationServices.h>
 #include "osx/osxvcltypes.h"
 #include "osx/salframe.h"
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060
+// The following symbols are SPI (System Programming Interface) in 10.5.
+extern "C" {
+    void CTRunGetAdvances(CTRunRef run, CFRange range, CGSize buffer[]);
+    const CGSize* CTRunGetAdvancesPtr(CTRunRef run);
+    extern const CFStringRef kCTTypesetterOptionForcedEmbeddingLevel;
+}
+#endif
 #else
 #include <CoreGraphics/CoreGraphics.h>
 #include <CoreText/CoreText.h>
diff --git a/vcl/quartz/ctfonts.cxx b/vcl/quartz/ctfonts.cxx
index ea89b53..72bc087 100644
--- a/vcl/quartz/ctfonts.cxx
+++ b/vcl/quartz/ctfonts.cxx
@@ -80,9 +80,13 @@ CoreTextStyle::CoreTextStyle( const FontSelectPattern& rFSD )
          ((mpFontData->GetWeight() < WEIGHT_SEMIBOLD) &&
           (mpFontData->GetWeight() != WEIGHT_DONTKNOW)) )
     {
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
         int nStroke = -10.0;
         CFNumberRef rStroke = CFNumberCreate(NULL, kCFNumberSInt32Type, &nStroke);
         CFDictionarySetValue(mpStyleDict, kCTStrokeWidthAttributeName, rStroke);
+#else /* kCTStrokeWidthAttributeName is not available */
+        /* do we really need "fake" bold? */
+#endif
     }
 
     // fake italic
@@ -335,9 +339,11 @@ ImplDevFontAttributes DevFontFromCTFontDescriptor( CTFontDescriptorRef pFD, bool
 
     // get font-enabled status
     if( bFontEnabled ) {
-        int bEnabled = FALSE;
+        int bEnabled = TRUE; // by default (and when we're on OS X < 10.6) it's "enabled"
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
         CFNumberRef pEnabled = (CFNumberRef)CTFontDescriptorCopyAttribute( pFD, kCTFontEnabledAttribute );
         CFNumberGetValue( pEnabled, kCFNumberIntType, &bEnabled );
+#endif
         *bFontEnabled = bEnabled;
     }
 
diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx
index d826215..41e1b49 100644
--- a/vcl/quartz/salgdi.cxx
+++ b/vcl/quartz/salgdi.cxx
@@ -337,16 +337,32 @@ static bool AddTempDevFont(const OUString& rFontFileURL)
     CFStringRef rFontPath = CFStringCreateWithCString(NULL, aCFileName.getStr(), kCFStringEncodingUTF8);
     CFURLRef rFontURL = CFURLCreateWithFileSystemPath(NULL, rFontPath, kCFURLPOSIXPathStyle, true);
 
-    CFErrorRef error;
-    bool success = CTFontManagerRegisterFontsForURL(rFontURL, kCTFontManagerScopeProcess, &error);
+    bool success = false;
 
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
+    CFErrorRef error;
+    success = CTFontManagerRegisterFontsForURL(rFontURL, kCTFontManagerScopeProcess, &error);
     if (!success)
     {
         CFRelease(error);
-        return false;
     }
+#else /* CTFontManagerRegisterFontsForURL is not available on OS X <10.6 */
+    CGDataProviderRef dataProvider = CGDataProviderCreateWithURL(rFontURL);
+    CGFontRef graphicsFont = CGFontCreateWithDataProvider(dataProvider);
+    if (graphicsFont)
+    {
+        CTFontRef coreTextFont = CTFontCreateWithGraphicsFont(graphicsFont, /*fontSize*/ 0, /*matrix*/ NULL, /*attributes*/ NULL);
+        if (coreTextFont)
+        {
+            success = true;
+            CFRelease(coreTextFont);
+        }
+        CGFontRelease(graphicsFont);
+    }
+    CGDataProviderRelease(dataProvider);
+#endif
 
-    return true;
+    return success;
 }
 
 static void AddTempFontDir( const OUString &rFontDirUrl )


More information about the Libreoffice-commits mailing list