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