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