summaryrefslogtreecommitdiff
path: root/src/gfx.cpp
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2013-08-05 20:35:23 +0000
committermichi_cc <michi_cc@openttd.org>2013-08-05 20:35:23 +0000
commit33f3cf3a5daeaf9e6e5b5414696f93676249bc41 (patch)
tree9de7c6fec9a311f66a3e598cdb3286cfdd1cadff /src/gfx.cpp
parent9d7ec75fc0a396b47f91a5f7ec4bea59024fea5f (diff)
downloadopenttd-33f3cf3a5daeaf9e6e5b5414696f93676249bc41.tar.xz
(svn r25651) -Fix: Textbuf caret rendering for complex scripts (e.g. Tamil).
Diffstat (limited to 'src/gfx.cpp')
-rw-r--r--src/gfx.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/gfx.cpp b/src/gfx.cpp
index 3278f972c..0e72e23d7 100644
--- a/src/gfx.cpp
+++ b/src/gfx.cpp
@@ -708,6 +708,20 @@ Dimension GetStringBoundingBox(StringID strid)
}
/**
+ * Get the leading corner of a character in a single-line string relative
+ * to the start of the string.
+ * @param str String containing the character.
+ * @param ch Pointer to the character in the string.
+ * @param start_fontsize Font size to start the text with.
+ * @return Upper left corner of the glyph associated with the character.
+ */
+Point GetCharPosInString(const char *str, const char *ch, FontSize start_fontsize)
+{
+ Layouter layout(str, INT32_MAX, TC_FROMSTRING, start_fontsize);
+ return layout.GetCharPosition(ch);
+}
+
+/**
* Draw single character horizontally centered around (x,y)
* @param c Character (glyph) to draw
* @param x X position to draw character