3 * (c) 2010 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
4 * Alexander Warg <warg@os.inf.tu-dresden.de>
5 * economic rights: Technische Universität Dresden (Germany)
7 * This file is part of TUD:OS and distributed under the terms of the
8 * GNU General Public License 2.
9 * Please see the COPYING-GPL-2 file for details.
13 #include <l4/sys/types.h>
15 #include <l4/mag-gfx/geometry>
21 unsigned char const *img;
22 l4_int32_t const *wtab, *otab;
25 explicit Font(void const *_ttf)
27 char const *ttf = (char const *)_ttf;
29 otab = (l4_int32_t const *)ttf;
30 wtab = (l4_int32_t const *)(ttf + 1024);
31 w = *(l4_int32_t const *)(ttf + 2048);
32 h = *(l4_int32_t const *)(ttf + 2052);
33 img = (unsigned char const *)(ttf + 2056);
37 * Calculate width of string when printed with the font
39 int str_w(char const *_str) const
41 unsigned char const *str = (unsigned char const *)_str;
43 for (; str && *str; ++str)
49 int str_w(char const *_str, int len) const
51 unsigned char const *str = (unsigned char const *)_str;
53 for (; str && *str && len; ++str, --len)
60 * Calculate height of string when printed with the font
62 int str_h(char const *) const { return h; }
63 int str_h(char const *, int) const { return h; }
65 Area str_sz(char const *s) const
66 { return Area(str_w(s), str_h(s)); }
68 Area str_sz(char const *s, int l) const
69 { return Area(str_w(s, l), str_h(s, l)); }