diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gfx.cpp | 10 | ||||
-rw-r--r-- | src/gfx_func.h | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/gfx.cpp b/src/gfx.cpp index 8d0add677..cb03ea7d5 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -729,6 +729,16 @@ int GetStringHeight(StringID str, int maxw) return GetMultilineStringHeight(buffer, GB(tmp, 0, 16)); } +/** Calculate string bounding box for multi-line strings. + * @param str String to check. + * @param suggestion Suggested bounding box. + * @return Bounding box for the multi-line string, may be bigger than \a suggestion. + */ +Dimension GetStringMultiLineBoundingBox(StringID str, const Dimension &suggestion) +{ + Dimension box = {suggestion.width, GetStringHeight(str, suggestion.width)}; + return box; +} /** * Draw string, possibly over multiple lines. diff --git a/src/gfx_func.h b/src/gfx_func.h index 08635d194..5dbef7917 100644 --- a/src/gfx_func.h +++ b/src/gfx_func.h @@ -117,6 +117,7 @@ Dimension GetStringBoundingBox(const char *str); Dimension GetStringBoundingBox(StringID strid); uint32 FormatStringLinebreaks(char *str, int maxw); int GetStringHeight(StringID str, int maxw); +Dimension GetStringMultiLineBoundingBox(StringID str, const Dimension &suggestion); void LoadStringWidthTable(); /** |