]> icculus.org git repositories - btb/d2x.git/blob - main/gamefont.c
use the orientation parameter of g3_draw_bitmap
[btb/d2x.git] / main / gamefont.c
1 /*
2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
11 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
12 */
13
14 /*
15  *
16  * Fonts for the game.
17  *
18  */
19
20 #ifdef HAVE_CONFIG_H
21 #include <conf.h>
22 #endif
23
24 #include <stdlib.h>
25
26 #include "inferno.h"
27 #include "gr.h"
28
29
30 // if 1, use high-res versions of fonts
31 int FontHires = 0;
32 int FontHiresAvailable = 0;
33
34 static const char *const Gamefont_filenames[] = {
35                                 "font1-1.fnt",      // Font 0
36                                 "font1-1h.fnt",     // Font 0 High-res
37                                 "font2-1.fnt",      // Font 1
38                                 "font2-1h.fnt",     // Font 1 High-res
39                                 "font2-2.fnt",      // Font 2
40                                 "font2-2h.fnt",     // Font 2 High-res
41                                 "font2-3.fnt",      // Font 3
42                                 "font2-3h.fnt",     // Font 3 High-res
43                                 "font3-1.fnt",      // Font 4
44                                 "font3-1h.fnt",     // Font 4 High-res
45                               };
46
47 grs_font *Gamefonts[MAX_FONTS];
48
49 int Gamefont_installed = 0;
50
51 void gamefont_init()
52 {
53         int i;
54
55         if (Gamefont_installed)
56                 return;
57         Gamefont_installed = 1;
58         FontHiresAvailable = 1;
59
60         for (i = 0; i < MAX_FONTS; i += 2)
61                 Gamefonts[i] = gr_init_font(Gamefont_filenames[i]);
62         for (i = 1; i < MAX_FONTS; i += 2)
63         {
64                 Gamefonts[i] = gr_init_font(Gamefont_filenames[i]);
65                 if (!Gamefonts[i])
66                         FontHiresAvailable = 0;
67         }
68
69         atexit(gamefont_close);
70 }
71
72
73 void gamefont_close()
74 {
75         int i;
76
77         if (!Gamefont_installed)
78                 return;
79         Gamefont_installed = 0;
80
81         for (i = 0; i < MAX_FONTS; i++)
82         {
83                 gr_close_font(Gamefonts[i]);
84                 Gamefonts[i] = NULL;
85         }
86 }