1 #ifndef _font_h_included
2 #define _font_h_included 1
3 
4 	#ifdef __cplusplus
5 		// Necessary header files for the C++ stuff:
6 		#ifndef _projtext
7 		#include "projtext.h"
8 		#endif
9 	#endif
10 
11 #include "aw.h"
12 
13 /************* fonts. not set up yet************/
14 
15 typedef enum fonts
16 {
17 	MENU_FONT_1,
18 	DATABASE_FONT_DARK,
19 	DATABASE_FONT_LITE,
20 	DATABASE_MESSAGE_FONT,
21 
22 	IntroFont_Dark,
23 	IntroFont_Light,
24 
25 	NUM_FONTS,
26 
27 }AVP_FONTS;
28 
29 #define MAXNUM_CHARS_IN_FONT (0x7e)
30 
31 
32 /* platform dependent character descriptor
33 
34 we dont need give any info apart from the size and src of the
35 thing to BLT for W95. The textprint routines will handle the
36 position of the surface on the screen
37 
38 */
39 
40 typedef enum font_types
41 {
42 	I_FONT_NUMERIC,
43 	I_FONT_UC_NUMERIC,
44 	I_FONT_UCLC_NUMERIC,
45 }FONT_TYPE;
46 
47 /* NUMERIC - COUNTS FROM ASCII 0x30 to 0x39 inc*/
48 /* UC NUMERIC 0x20 t0 0x5A				*/
49 /* UCLC_NUMERIC 0cx20 to 0x7E inc */
50 
51 
52 // menu strings - printed to the creen with a certain
53 // justification
54 
55 typedef enum font_justification
56 {
57 	FJ_LEFT_JUST,
58 	FJ_CENTRED,
59 	FJ_RIGHT_JUST,
60 }FONT_JUST;
61 
62 
63 // bitfield of flags
64 
65 typedef struct
66 {
67 	unsigned int loaded  : 1;
68 
69 }FONT_FLAGS;
70 
71 
72 typedef struct pffont
73 {
74 	LPDIRECTDRAWSURFACE data;	 	/*LPDIRECTDRAWSURFACE, etc - fill out*/
75 	char filename[100];			/*compile in -filename */
76 	int fontHeight;				/* max height of chars */
77 	int num_chars_in_font;			/*number of chars in this font */
78 	FONT_TYPE font_type;
79 	FONT_FLAGS flags;
80 	RECT srcRect[MAXNUM_CHARS_IN_FONT];  /*source rectangles*/
81 
82 	int fttexWidth;                       /* filled in during loading */
83 	int fttexHeight;
84 	int fttexBitDepth;
85 	unsigned hotSpotValue;
86 	AW_BACKUPTEXTUREHANDLE hBackup;
87 
88 	#ifdef __cplusplus
89 	// C++ methods: ////////////////////////////////
90 	int GetHeight(void) const;
91 	int GetWidth(const ProjChar ProjCh) const;
92 	int bPrintable(const ProjChar ProjCh) const;
93 	int ProjCharToOffset(const ProjChar ProjCh) const;
94 
95 	int GetOffset(void) const;
96 		// DHM 25/11/97:
97 		// Returns offset for subtracting from ASCII code to get
98 		// to index into the font
99 	int GetMinChar(void) const;
100 	int GetMaxChar(void) const;
101 		// returns extent within the ASCII set that can be printed (inclusive of boundary values)
102 
103 	#endif // __cplusplus
104 
105 }PFFONT;
106 
107 #ifdef __cplusplus
108 
109 	// Inline method implementations:
GetHeight(void)110 	inline int pffont::GetHeight(void) const
111 	{
112 		return fontHeight;
113 	}
GetWidth(const ProjChar ProjCh)114 	inline int pffont::GetWidth(const ProjChar ProjCh) const
115 	{
116 		if ( bPrintable(ProjCh) )
117 		{
118 			const RECT& charRect = srcRect[ ProjCharToOffset(ProjCh) ] ;
119 
120 			return (charRect . right - charRect . left);
121 		}
122 		else
123 		{
124 			return 0;
125 		}
126 	}
bPrintable(const ProjChar ProjCh)127 	inline int pffont::bPrintable(const ProjChar ProjCh) const
128 	{
129 		const int Offset = GetOffset();
130 
131 		if ( (int)ProjCh < Offset )
132 		{
133 			return No;
134 		}
135 		if ( (int)ProjCh >= Offset + num_chars_in_font )
136 		{
137 			return No;
138 		}
139 		return Yes;
140 	}
ProjCharToOffset(const ProjChar ProjCh)141 	inline int pffont::ProjCharToOffset(const ProjChar ProjCh) const
142 	{
143 		return ((int)ProjCh - GetOffset());
144 	}
GetOffset(void)145 	inline int pffont::GetOffset(void) const
146 	{
147 		// DHM 25/11/97:
148 		// Returns offset for subtracting from ASCII code to get
149 		// to index into the font
150 		if (font_type == I_FONT_NUMERIC)
151 		{
152 			return 0x30;
153 		}
154 		else
155 		{
156 			return 0x20;
157 		}
158 	}
GetMinChar(void)159 	inline int pffont::GetMinChar(void) const
160 	{
161 		return GetOffset();
162 	}
GetMaxChar(void)163 	inline int pffont::GetMaxChar(void) const
164 	{
165 		return (GetOffset() + num_chars_in_font -1);
166 	}
167 
168 
169 	extern "C" {
170 #endif
171 
172 // platform independent externs
173 extern void LoadAllFonts();
174 extern void LoadPFFont(int fontnum);
175 
176  // platform dependent callbacks for loading
177 extern void LoadFont(PFFONT *pffont);
178 extern void UnloadFont(PFFONT *pffont);
179 
180 extern void FillCharacterSlot(int u, int v, int width, int height,
181 								int charnum, PFFONT *font);
182 
183 extern int BLTFontOffsetToHUD(PFFONT* font , int xdest, int ydest, int offset);
184 
185 
186 /* to lock a font and get the raw data - pPitch receives the pitch of the surface */
187 extern void * FontLock(PFFONT const * pFont, unsigned * pPitch);
188 extern void FontUnlock(PFFONT const * pFont);
189 
190 
191 // the array of all the Fonts int the game
192 extern PFFONT AvpFonts[];
193 
194 #ifdef __cplusplus
195 	};
196 #endif
197 
198 #endif /* _font_h_included */
199 
200