summaryrefslogtreecommitdiff
path: root/src/gfx_layout.cpp
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2018-10-28 23:30:49 +0100
committerMichael Lutz <michi@icosahedron.de>2018-12-08 20:13:27 +0100
commit32ce1ce3473253644d1237227706e4f8ce55ab7a (patch)
tree59731354a3b4ced7e0f6040e696ff670e39d2d19 /src/gfx_layout.cpp
parent4bf216993a1df7a29922bf34e2d8191460842452 (diff)
downloadopenttd-32ce1ce3473253644d1237227706e4f8ce55ab7a.tar.xz
Add: [OSX] Text layout using the native CoreText API.
By default, the native API will be used instead of ICU, but if ICU is forced in using configure, it will take precedence.
Diffstat (limited to 'src/gfx_layout.cpp')
-rw-r--r--src/gfx_layout.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/gfx_layout.cpp b/src/gfx_layout.cpp
index c493e69c3..c65ead90e 100644
--- a/src/gfx_layout.cpp
+++ b/src/gfx_layout.cpp
@@ -25,6 +25,10 @@
#include "os/windows/string_uniscribe.h"
#endif /* WITH_UNISCRIBE */
+#ifdef WITH_COCOA
+#include "os/macosx/string_osx.h"
+#endif
+
#include "safeguards.h"
@@ -670,7 +674,7 @@ Layouter::Layouter(const char *str, int maxw, TextColour colour, FontSize fontsi
} else {
/* Line is new, layout it */
FontState old_state = state;
-#if defined(WITH_ICU_LAYOUT) || defined(WITH_UNISCRIBE)
+#if defined(WITH_ICU_LAYOUT) || defined(WITH_UNISCRIBE) || defined(WITH_COCOA)
const char *old_str = str;
#endif
@@ -698,6 +702,16 @@ Layouter::Layouter(const char *str, int maxw, TextColour colour, FontSize fontsi
}
#endif
+#ifdef WITH_COCOA
+ if (line.layout == NULL) {
+ GetLayouter<CoreTextParagraphLayoutFactory>(line, str, state);
+ if (line.layout == NULL) {
+ state = old_state;
+ str = old_str;
+ }
+ }
+#endif
+
if (line.layout == NULL) {
GetLayouter<FallbackParagraphLayoutFactory>(line, str, state);
}
@@ -841,6 +855,9 @@ void Layouter::ResetFontCache(FontSize size)
#if defined(WITH_UNISCRIBE)
UniscribeResetScriptCache(size);
#endif
+#if defined(WITH_COCOA)
+ MacOSResetScriptCache(size);
+#endif
}
/**