summaryrefslogtreecommitdiff
path: root/src/os/macosx/string_osx.h
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/os/macosx/string_osx.h
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/os/macosx/string_osx.h')
-rw-r--r--src/os/macosx/string_osx.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/os/macosx/string_osx.h b/src/os/macosx/string_osx.h
index ea7904f54..d632b0a44 100644
--- a/src/os/macosx/string_osx.h
+++ b/src/os/macosx/string_osx.h
@@ -38,7 +38,52 @@ public:
static StringIterator *Create();
};
+/**
+ * Helper class to construct a new #CoreTextParagraphLayout.
+ */
+class CoreTextParagraphLayoutFactory {
+public:
+ /** Helper for GetLayouter, to get the right type. */
+ typedef UniChar CharType;
+ /** Helper for GetLayouter, to get whether the layouter supports RTL. */
+ static const bool SUPPORTS_RTL = true;
+
+ /**
+ * Get the actual ParagraphLayout for the given buffer.
+ * @param buff The begin of the buffer.
+ * @param buff_end The location after the last element in the buffer.
+ * @param fontMapping THe mapping of the fonts.
+ * @return The ParagraphLayout instance.
+ */
+ static ParagraphLayouter *GetParagraphLayout(CharType *buff, CharType *buff_end, FontMap &fontMapping);
+
+ /**
+ * Append a wide character to the internal buffer.
+ * @param buff The buffer to append to.
+ * @param buffer_last The end of the buffer.
+ * @param c The character to add.
+ * @return The number of buffer spaces that were used.
+ */
+ static size_t AppendToBuffer(CharType *buff, const CharType *buffer_last, WChar c)
+ {
+ if (c >= 0x010000U) {
+ /* Character is encoded using surrogates in UTF-16. */
+ if (buff + 1 <= buffer_last) {
+ buff[0] = (CharType)(((c - 0x010000U) >> 10) + 0xD800);
+ buff[1] = (CharType)(((c - 0x010000U) & 0x3FF) + 0xDC00);
+ } else {
+ /* Not enough space in buffer. */
+ *buff = 0;
+ }
+ return 2;
+ } else {
+ *buff = (CharType)(c & 0xFFFF);
+ return 1;
+ }
+ }
+};
+void MacOSResetScriptCache(FontSize size);
void MacOSSetCurrentLocaleName(const char *iso_code);
int MacOSStringCompare(const char *s1, const char *s2);