1 | // ==================================================================== // |
---|
2 | // // |
---|
3 | // File : AW_font_group.cxx // |
---|
4 | // Purpose : Bundles a group of fonts and provides overall maximas // |
---|
5 | // // |
---|
6 | // // |
---|
7 | // Coded by Ralf Westram (coder@reallysoft.de) in December 2004 // |
---|
8 | // Copyright Department of Microbiology (Technical University Munich) // |
---|
9 | // // |
---|
10 | // Visit our web site at: http://www.arb-home.de/ // |
---|
11 | // // |
---|
12 | // ==================================================================== // |
---|
13 | |
---|
14 | #include "aw_font_group.hxx" |
---|
15 | #include <cstring> |
---|
16 | |
---|
17 | // ____________________________________________________________ |
---|
18 | // start of implementation of class AW_font_group: |
---|
19 | |
---|
20 | AW_font_group::AW_font_group() { |
---|
21 | unregisterAll(); |
---|
22 | } |
---|
23 | |
---|
24 | void AW_font_group::unregisterAll() |
---|
25 | { |
---|
26 | max_width = 0; |
---|
27 | max_ascent = 0; |
---|
28 | max_descent = 0; |
---|
29 | max_height = 0; |
---|
30 | |
---|
31 | memset(&max_letter_limits[0], 0, sizeof(max_letter_limits)); |
---|
32 | } |
---|
33 | |
---|
34 | inline void set_max(int val, int& max) { if (val>max) max = val; } |
---|
35 | |
---|
36 | void AW_font_group::registerFont(AW_device *device, int gc, const char *chars) { |
---|
37 | aw_assert(gc <= AW_FONT_GROUP_MAX_GC); |
---|
38 | |
---|
39 | if (!chars) { |
---|
40 | // use complete ASCII-range for limits |
---|
41 | max_letter_limits[gc] = device->get_font_information(gc, 0)->max_letter; |
---|
42 | } |
---|
43 | else { |
---|
44 | aw_assert(chars[0]); |
---|
45 | max_letter_limits[gc] = device->get_font_information(gc, chars[0])->this_letter; |
---|
46 | for (int i = 1; chars[i]; ++i) { |
---|
47 | max_letter_limits[gc] = AW_font_limits(max_letter_limits[gc], |
---|
48 | device->get_font_information(gc, chars[i])->this_letter); |
---|
49 | } |
---|
50 | } |
---|
51 | |
---|
52 | set_max(get_width(gc), max_width); |
---|
53 | set_max(get_ascent(gc), max_ascent); |
---|
54 | set_max(get_descent(gc), max_descent); |
---|
55 | set_max(get_height(gc), max_height); |
---|
56 | } |
---|
57 | |
---|
58 | |
---|
59 | // -end- of implementation of class AW_font_group. |
---|
60 | |
---|
61 | |
---|
62 | |
---|
63 | |
---|