| |
1 #include "gntutils.h" |
| |
2 |
| |
3 void gnt_util_get_text_bound(const char *text, int *width, int *height) |
| |
4 { |
| |
5 const char *s = text, *last; |
| |
6 int count = 1, max = 0; |
| |
7 int len; |
| |
8 |
| |
9 /* XXX: ew ... everyone look away */ |
| |
10 last = s; |
| |
11 while (*s) |
| |
12 { |
| |
13 if (*s == '\n' || *s == '\r') |
| |
14 { |
| |
15 count++; |
| |
16 len = g_utf8_pointer_to_offset(last, s); |
| |
17 if (max < len) |
| |
18 max = len; |
| |
19 last = s + 1; |
| |
20 } |
| |
21 s++; |
| |
22 } |
| |
23 |
| |
24 len = g_utf8_pointer_to_offset(last, s); |
| |
25 if (max < len) |
| |
26 max = len; |
| |
27 |
| |
28 if (height) |
| |
29 *height = count; |
| |
30 if (width) |
| |
31 *width = max + (count > 1); |
| |
32 } |
| |
33 |