diff options
author | Douglas Mencken <dougmencken@gmail.com> | 2014-02-22 14:24:45 -0500 |
---|---|---|
committer | Norbert Thiebaud <nthiebaud@gmail.com> | 2014-02-23 19:05:16 +0000 |
commit | ae4a8c6152a6234eed52482da64d84ad5a56c03d (patch) | |
tree | 8799271df8daecb7d7c0147ea99d2e29264f615d /vcl | |
parent | b0073ef79efe65d8094d479faf0c4b657dffbfb0 (diff) |
CoreText SDK 10.5 compatibility
Change-Id: Ic876ec473b1c03a70c160af4251c68b299b27eca
Reviewed-on: https://gerrit.libreoffice.org/7143
Reviewed-by: Norbert Thiebaud <nthiebaud@gmail.com>
Tested-by: Norbert Thiebaud <nthiebaud@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/quartz/salgdi.h | 9 | ||||
-rw-r--r-- | vcl/quartz/ctfonts.cxx | 8 | ||||
-rw-r--r-- | vcl/quartz/salgdi.cxx | 24 |
3 files changed, 36 insertions, 5 deletions
diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h index 7cd2e83264da..a6c8a8ce003f 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 ea89b5318f8d..72bc087ca368 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 d82621576e34..41e1b492baa6 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 ) |