File: fontdata.c

package info (click to toggle)
splat 1.2.1-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 1,144 kB
  • ctags: 238
  • sloc: cpp: 6,260; ansic: 761; sh: 251; lisp: 244; makefile: 54
file content (92 lines) | stat: -rw-r--r-- 3,168 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/****************************************************************************
*                  FONTDATA:  A "fontdata.h" File Generator                 *
*                  Copyright John A. Magliacane, KD2BD 2002                 *
*                         Last update: 13-Apr-2002                          *
*****************************************************************************
*                                                                           *
* This utility reads gzip compressed font data, and generates a fontdata.h  *
* file required for compilation of SPLAT!.  Slackware Linux users may       *
* find compatible console font data files under /usr/lib/kbd/consolefonts   *
* (Slackware < version 8), or /usr/share/kbd/consolefonts (Slackware 8).    *
*                                                                           *
*                       Example: fontdata s.fnt.gz                          *
*   Writes s.fnt font data to "fontdata.h" in current working directory.    *
*                                                                           *
*****************************************************************************
*          To compile: gcc -Wall -O6 -s -lz fontdata.c -o fontdata          *
*****************************************************************************
*                                                                           *
* This program is free software; you can redistribute it and/or modify it   *
* under the terms of the GNU General Public License as published by the     *
* Free Software Foundation; either version 2 of the License or any later    *
* version.                                                                  *
*                                                                           *
* This program is distributed in the hope that it will useful, but WITHOUT  *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or     *
* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License     *
* for more details.                                                         *
*                                                                           *
*****************************************************************************/

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <zlib.h>
#include <stdlib.h>

int main(argc,argv)
int argc;
char *argv[];
{
	int x;
	unsigned char line, input;
	FILE *infile, *outfile;
	
	if (argc==2)
		infile=gzopen(argv[1],"rb");

	else
	{	
		fprintf(stderr,"Usage: fontdata fontfile.gz\n");
		exit(-1);
	}

	if (infile!=NULL)
	{
		outfile=fopen("fontdata.h","wb");

		fprintf(outfile,"static char fontdata[] = {\n  ");

		for (x=0, line=0; x<4096; x++)
		{
			input=gzgetc(infile);
			
			fprintf(outfile," 0x%.2x",input);
	   		line++;

			if (x<4095)
				fprintf(outfile,",");

			if (line==12)
			{
				fprintf(outfile,"\n  ");
				line=0;
			}
		}

	 	fprintf(outfile," };\n");

		gzclose(infile);
		fclose(outfile);

		printf("fontdata.h successfully written!\n");
	}

	else
	{
		fprintf(stderr,"%c*** Error: %c%s%c Not Found!\n",7,34,argv[1],34);
		exit(-1);
	}

	exit(0);
}