1 | /********************************************************************** <BR>
|
---|
2 | This file is part of Crack dot Com's free source code release of
|
---|
3 | Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
|
---|
4 | information about compiling & licensing issues visit this URL</a>
|
---|
5 | <PRE> If that doesn't help, contact Jonathan Clark at
|
---|
6 | golgotha_source@usa.net (Subject should have "GOLG" in it)
|
---|
7 | ***********************************************************************/
|
---|
8 |
|
---|
9 | #ifndef __PLAIN_FONT_HPP_
|
---|
10 | #define __PLAIN_FONT_HPP_
|
---|
11 |
|
---|
12 | #include "font/font.hh"
|
---|
13 | #include "image/image.hh"
|
---|
14 |
|
---|
15 | /* This is a quick and dirty implementation of a font
|
---|
16 | It uses a bitmap arranged 32 across and 8 down and
|
---|
17 | grabs a small part which is placed on the screen per letter.
|
---|
18 | The color of the font is changed by loading in a new palette
|
---|
19 | for the bitmap and letting copy_from() do the color remapping.
|
---|
20 |
|
---|
21 | Exmaple ussage :
|
---|
22 |
|
---|
23 | i4_const_str s=i4gets("font1_image_filename"); // get the filename from the resource file
|
---|
24 | i4_image_class *font_image=i4_load_image(s); // load the bitmap
|
---|
25 | i4_plain_font_class *font=new i4_plain_font_class(im); // create the font
|
---|
26 |
|
---|
27 |
|
---|
28 | TODO :
|
---|
29 | fonts should probably loaded through a resource name.
|
---|
30 | i.e.
|
---|
31 | i4_load_font(const i4_const_str &resource_name);
|
---|
32 | */
|
---|
33 |
|
---|
34 | class i4_plain_font_class : public i4_font_class
|
---|
35 | {
|
---|
36 | i4_image_class *bitmap;
|
---|
37 | w16 w,h;
|
---|
38 | public :
|
---|
39 | i4_plain_font_class(i4_image_class *bitmap); // bitmap is copied and stored internally
|
---|
40 |
|
---|
41 | virtual void set_color(i4_color color);
|
---|
42 |
|
---|
43 | virtual void put_string(i4_image_class *screen,
|
---|
44 | sw16 x, sw16 y,
|
---|
45 | const i4_const_str &string,
|
---|
46 | i4_draw_context_class &context);
|
---|
47 |
|
---|
48 | virtual void put_character(i4_image_class *screen,
|
---|
49 | sw16 x, sw16 y,
|
---|
50 | const i4_char &c,
|
---|
51 | i4_draw_context_class &context);
|
---|
52 |
|
---|
53 | virtual w16 width(const i4_char &character) { return w; } // width in pixels
|
---|
54 | virtual w16 height(const i4_char &character) { return h; } // height in pixels
|
---|
55 |
|
---|
56 | virtual w16 width(const i4_const_str &string) { return string.length()*w; } // width in pixels
|
---|
57 | virtual w16 height(const i4_const_str &string) { return h; } // height in pixels
|
---|
58 |
|
---|
59 | virtual w16 largest_height() { return h; }
|
---|
60 | virtual w16 largest_width() { return w; }
|
---|
61 | virtual ~i4_plain_font_class();
|
---|
62 | } ;
|
---|
63 |
|
---|
64 | #endif
|
---|
65 |
|
---|