]> icculus.org git repositories - taylor/freespace2.git/blob - include/font.h
Initial revision
[taylor/freespace2.git] / include / font.h
1 /*7
2  * $Logfile: /Freespace2/code/Graphics/Font.h $
3  * $Revision$
4  * $Date$
5  * $Author$
6  *
7  * header file for font stuff
8  *
9  * $Log$
10  * Revision 1.1  2002/05/03 03:28:12  root
11  * Initial revision
12  *
13  * 
14  * 4     7/09/99 10:32p Dave
15  * Command brief and red alert screens.
16  * 
17  * 3     10/13/98 9:28a Dave
18  * Started neatening up freespace.h. Many variables renamed and
19  * reorganized. Added AlphaColors.[h,cpp]
20  * 
21  * 2     10/07/98 10:52a Dave
22  * Initial checkin.
23  * 
24  * 1     10/07/98 10:49a Dave
25  * 
26  * 14    5/25/98 10:32a John
27  * Took out redundant code for font bitmap offsets that converted to a
28  * float, then later on converted back to an integer.  Quite unnecessary.
29  * 
30  * 13    3/25/98 8:07p John
31  * Restructured software rendering into two modules; One for windowed
32  * debug mode and one for DirectX fullscreen.   
33  * 
34  * 12    3/10/98 4:18p John
35  * Cleaned up graphics lib.  Took out most unused gr functions.   Made D3D
36  * & Glide have popups and print screen.  Took out all >8bpp software
37  * support.  Made Fred zbuffer.  Made zbuffer allocate dynamically to
38  * support Fred.  Made zbuffering key off of functions rather than one
39  * global variable.
40  * 
41  * 11    3/09/98 6:06p John
42  * Restructured font stuff to avoid duplicate code in Direct3D and Glide.
43  * Restructured Glide to avoid redundent state setting.
44  * 
45  * 10    2/19/98 9:04a John
46  * Fixed fonts with glide
47  * 
48  * 9     2/17/98 7:27p John
49  * Got fonts and texturing working in Direct3D
50  * 
51  * 8     11/30/97 12:18p John
52  * added more 24 & 32-bpp primitives
53  * 
54  * 7     11/06/97 5:42p Hoffoss
55  * Added support for fixed size timstamp rendering.
56  * 
57  * 6     11/03/97 10:59a John
58  * added support for more than one font.
59  * 
60  * 5     10/24/97 12:13p Hoffoss
61  * Added gr_force_fit_string().
62  * 
63  * 4     10/09/97 5:23p John
64  * Added support for more 16-bpp functions
65  * 
66  * 3     6/05/97 4:53p John
67  * First rev of new antialiased font stuff.
68  * 
69  * 2     4/22/97 10:33a John
70  * fixed the 2d resource leaks that Alan found.
71  * 
72  * 1     3/31/97 9:42a Allender
73  *
74  * $NoKeywords: $
75  */
76
77 #ifndef _FONT_H
78 #define _FONT_H
79
80 #include "pstypes.h"
81
82 #define MAX_FONTS 3
83
84 #define FONT_VERSION 0
85 #define WIDEST_DIGIT    "4"  // the widest number character
86 #define WIDEST_CHAR     "W"  // the widest character
87
88 typedef struct font_char {
89         int                             spacing;
90         int                             byte_width;
91         int                             offset;
92         short                           kerning_entry;
93         short                           user_data;
94 } font_char;
95
96 typedef struct font_kernpair {
97         char                            c1,c2;
98         signed char             offset;
99 } font_kernpair;
100
101
102 typedef struct font {
103         char                            filename[MAX_FILENAME_LEN];
104         int                             id;                     // Should be 'VFNT'
105         int                             version;                        // font version
106         int                             num_chars;
107         int                             first_ascii;
108         int                             w;
109         int                             h;
110         int                             num_kern_pairs;
111         int                             kern_data_size;
112         int                             char_data_size;
113         int                             pixel_data_size;
114         font_kernpair   *kern_data;
115         font_char               *char_data;
116         ubyte                           *pixel_data;
117
118         // Data for 3d cards
119         int                             bitmap_id;                      // A bitmap representing the font data
120         int                             bm_w, bm_h;                     // Bitmap width and height
121         ubyte                           *bm_data;                       // The actual font data
122         int                             *bm_u;                          // U offset of each character
123         int                             *bm_v;                          // V offset of each character
124
125 } font;
126
127 extern int Num_fonts;
128 extern font Fonts[MAX_FONTS];
129 extern font *Current_font;
130
131 #define FONT1                           0                               // font01.vf
132 #define FONT2                           1                               // font02.vf
133 #define FONT3                           2                               // font03.vf
134
135 // extern definitions for basic font functions
136 extern void grx_set_font(int fontnum);
137 extern void gr8_string(int x,int y,char * text);
138
139 void gr_print_timestamp(int x, int y, int timestamp);
140 char *gr_force_fit_string(char *str, int max_str, int max_width);
141 void gr_font_init();
142 void gr_font_close();
143
144 extern font * Current_font;
145 extern int get_char_width(ubyte c1,ubyte c2,int *width,int *spacing);
146 extern int get_centered_x(char *s);
147
148 #endif
149