diff -r c7e54fa6147e -r 3d8804b82150 console/libgnt/gntutils.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/console/libgnt/gntutils.c Wed Aug 09 03:41:45 2006 +0000 @@ -0,0 +1,33 @@ +#include "gntutils.h" + +void gnt_util_get_text_bound(const char *text, int *width, int *height) +{ + const char *s = text, *last; + int count = 1, max = 0; + int len; + + /* XXX: ew ... everyone look away */ + last = s; + while (*s) + { + if (*s == '\n' || *s == '\r') + { + count++; + len = g_utf8_pointer_to_offset(last, s); + if (max < len) + max = len; + last = s + 1; + } + s++; + } + + len = g_utf8_pointer_to_offset(last, s); + if (max < len) + max = len; + + if (height) + *height = count; + if (width) + *width = max + (count > 1); +} +