aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-03-27 13:56:34 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-03-27 13:56:34 +0000
commit3dcbd4673d7ee03ded1c08e6d58713cb07e9d1f1 (patch)
treeb3e7d7f8148f790f623072443cc4d1b7dddadfc1
parent37cbc7fd014e3b35833523dbdbe3bc3ac52ecacd (diff)
CTFontManagerCopyAvailableFontFamilyNames is not always available (on iOS)
so write a wrapper for it. fixes iOS build git-svn-id: http://skia.googlecode.com/svn/trunk@8406 2bbb7eff-a529-9590-31e7-b0007b416f81
-rwxr-xr-xsrc/ports/SkFontHost_mac.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/ports/SkFontHost_mac.cpp b/src/ports/SkFontHost_mac.cpp
index d204b1361d..2b2410996f 100755
--- a/src/ports/SkFontHost_mac.cpp
+++ b/src/ports/SkFontHost_mac.cpp
@@ -13,6 +13,7 @@
#ifdef SK_BUILD_FOR_IOS
#include <CoreText/CoreText.h>
+#include <CoreText/CTFontManager.h>
#include <CoreGraphics/CoreGraphics.h>
#include <CoreFoundation/CoreFoundation.h>
#endif
@@ -44,6 +45,17 @@
class SkScalerContext_Mac;
+// CTFontManagerCopyAvailableFontFamilyNames() is not always available, so we
+// provide a wrapper here that will return an empty array if need be.
+static CFArrayRef SkCTFontManagerCopyAvailableFontFamilyNames() {
+#ifdef SK_BUILD_FOR_IOS
+ return CFArrayCreate(NULL, NULL, 0, NULL);
+#else
+ return CTFontManagerCopyAvailableFontFamilyNames();
+#endif
+}
+
+
// Being templated and taking const T* prevents calling
// CFSafeRelease(autoCFRelease) through implicit conversion.
template <typename T> static void CFSafeRelease(/*CFTypeRef*/const T* cfTypeRef) {
@@ -1998,7 +2010,7 @@ class SkFontMgr_Mac : public SkFontMgr {
void lazyInit() {
if (NULL == fNames) {
- fNames = CTFontManagerCopyAvailableFontFamilyNames();
+ fNames = SkCTFontManagerCopyAvailableFontFamilyNames();
fCount = fNames ? CFArrayGetCount(fNames) : 0;
}
}