summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2020-04-10 14:13:56 +0200
committerMichael Lutz <michi@icosahedron.de>2020-04-12 18:44:43 +0200
commit9d7ad67c1d0577a091c09eb7e0ac2b1b7bc12d3a (patch)
treedbefb1af91b9a2b49ca4837f52f8d35e8b64d8bf
parente90d065f11c22f17744e08877bc6b47dc81a5f90 (diff)
downloadopenttd-9d7ad67c1d0577a091c09eb7e0ac2b1b7bc12d3a.tar.xz
Codechange: [OSX] Allow compiling with SDK version pre 10.9.
-rw-r--r--src/os/macosx/osx_stdafx.h4
-rw-r--r--src/os/macosx/string_osx.cpp29
2 files changed, 33 insertions, 0 deletions
diff --git a/src/os/macosx/osx_stdafx.h b/src/os/macosx/osx_stdafx.h
index 476362ccc..d90a19c5f 100644
--- a/src/os/macosx/osx_stdafx.h
+++ b/src/os/macosx/osx_stdafx.h
@@ -18,6 +18,10 @@
#define HAVE_OSX_107_SDK
#endif
+#ifdef MAC_OS_X_VERSION_10_9
+#define HAVE_OSX_109_SDK
+#endif
+
#ifdef MAC_OS_X_VERSION_10_11
#define HAVE_OSX_1011_SDK
#endif
diff --git a/src/os/macosx/string_osx.cpp b/src/os/macosx/string_osx.cpp
index 63be4d3ad..ad4983e9a 100644
--- a/src/os/macosx/string_osx.cpp
+++ b/src/os/macosx/string_osx.cpp
@@ -19,6 +19,35 @@
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
+
+/* CTRunDelegateCreate is supported since MacOS X 10.5, but was only included in the SDKs starting with the 10.9 SDK. */
+#ifndef HAVE_OSX_109_SDK
+extern "C" {
+ typedef const struct __CTRunDelegate * CTRunDelegateRef;
+
+ typedef void (*CTRunDelegateDeallocateCallback) (void* refCon);
+ typedef CGFloat (*CTRunDelegateGetAscentCallback) (void* refCon);
+ typedef CGFloat (*CTRunDelegateGetDescentCallback) (void* refCon);
+ typedef CGFloat (*CTRunDelegateGetWidthCallback) (void* refCon);
+ typedef struct {
+ CFIndex version;
+ CTRunDelegateDeallocateCallback dealloc;
+ CTRunDelegateGetAscentCallback getAscent;
+ CTRunDelegateGetDescentCallback getDescent;
+ CTRunDelegateGetWidthCallback getWidth;
+ } CTRunDelegateCallbacks;
+
+ enum {
+ kCTRunDelegateVersion1 = 1,
+ kCTRunDelegateCurrentVersion = kCTRunDelegateVersion1
+ };
+
+ extern const CFStringRef kCTRunDelegateAttributeName AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+
+ CTRunDelegateRef CTRunDelegateCreate(const CTRunDelegateCallbacks* callbacks, void* refCon) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+}
+#endif /* HAVE_OSX_109_SDK */
+
/** Cached current locale. */
static CFAutoRelease<CFLocaleRef> _osx_locale;
/** CoreText cache for font information, cleared when OTTD changes fonts. */