2 Copyright (C) 1998 BJ Eirich (aka vecna)
\r
3 This program is free software; you can redistribute it and/or
\r
4 modify it under the terms of the GNU General Public License
\r
5 as published by the Free Software Foundation; either version 2
\r
6 of the License, or (at your option) any later version.
\r
7 This program is distributed in the hope that it will be useful,
\r
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
\r
10 See the GNU General Public Lic
\r
11 See the GNU General Public License for more details.
\r
12 You should have received a copy of the GNU General Public License
\r
13 along with this program; if not, write to the Free Software
\r
14 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
\r
20 // ================================= Data ====================================
\r
24 byte width, height; // Font character dimensions
\r
25 byte *data; // Font bitmap data
\r
28 struct fontstruct font[10]; // Font stuff;
\r
29 int numfonts=0; // number of loaded fonts.
\r
30 int curx, cury; // x/y font location
\r
31 char tc=0; // text color
\r
33 // ================================= Code ====================================
\r
35 int LoadFont(char *fname)
\r
37 struct fontstruct *cfont=0;
\r
40 if (!(f=vopen(fname)))
\r
41 err("Could not open font %s. \n",fname);
\r
43 // alias current font struct
\r
44 cfont=font+numfonts;
\r
47 err("Font file incorrect version number. \n");
\r
50 cfont->width=vgetw(f);
\r
51 cfont->height=vgetw(f);
\r
53 // get num of sub-set; calc total bytes as well
\r
54 z=vgetw(f) * 96 * cfont->width*cfont->height;
\r
56 // nab room for font and read it in
\r
57 cfont->data=(byte *)valloc(z, "LoadFont:cfont->data", OID_IMAGE);
\r
58 vread(cfont->data, z, f);
\r
65 void TextColor(int c)
\r
70 void GotoXY(int x, int y)
\r
76 static void pchar(int fnt, int x, int y, unsigned char c)
\r
81 w=font[fnt].width,h=font[fnt].height;
\r
82 TCopySpriteClip(x,y, w,h, font[fnt].data+((c-32)*w*h)+((tc&3)*96*w*h));
\r
86 void printstring(int fnt, char *str)
\r
88 if (fnt<0 || fnt >= numfonts)
\r
92 unsigned char c=*str;
\r
95 case 126: tc=0; str++; continue;
\r
96 case 128: tc=1; str++; continue;
\r
97 case 129: tc=2; str++; continue;
\r
98 case 130: tc=3; str++; continue;
\r
100 pchar(fnt,curx,cury,c);
\r
101 curx+=font[fnt].width;
\r