1 /*
2 * Mach Operating System
3 * Copyright (c) 1991,1990,1989 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the
9 * software, derivative works or modified versions, and any portions
10 * thereof, and that both notices appear in supporting documentation.
11 *
12 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15 *
16 * Carnegie Mellon requests users of this software to return to
17 *
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
22 *
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
25 */
26 /*
27 * HISTORY
28 * $Log: build_font.c,v $
29 * Revision 2.6 91/06/19 11:46:19 rvb
30 * File moved here from mips/PMAX since it tries to be generic;
31 * it is used on the PMAX and the Vax3100.
32 * [91/06/04 rvb]
33 *
34 * Revision 2.5 91/05/14 17:19:54 mrt
35 * Correcting copyright
36 *
37 * Revision 2.4 91/02/05 17:40:00 mrt
38 * Added author notices
39 * [91/02/04 11:12:16 mrt]
40 *
41 * Changed to use new Mach copyright
42 * [91/02/02 12:09:59 mrt]
43 *
44 * Revision 2.3 90/12/05 23:30:32 af
45 * Add Log entry to output file so that it can be RCS-ed.
46 * [90/12/03 23:11:04 af]
47 *
48 * Revision 2.1.1.1 90/11/01 03:11:00 af
49 * Created.
50 * [90/10/07 af]
51 */
52 /*
53 * File: build_font.c
54 * Author: Alessandro Forin, Carnegie Mellon University
55 * Date: 10/90
56 *
57 *
58 * Takes a font description file and generates a C source
59 * appropriate for use as kernel font on mips/vax boxes.
60 * This basically means encoding and mirroring the bitmaps.
61 */
62
63 #include <stdio.h>
64
65 main(argc,argv)
66 char **argv;
67 {
68 int fd;
69 FILE *fout;
70 int i, j, k, n, l;
71 int first, last;
72 char *fname = "kernel_font.data";
73 char buf[16*9];
74 int verbose = 0;
75
76 if (argc > 1 && argv[1][0] == '+')
77 verbose++, argc--, argv++;
78
79 first = 0;
80 last = 190; /* 8-bit ASCII, offset by 'space' */
81 if (argc > 1) {
82 first = atoi(argv[1]);
83 last = first + 1;
84 }
85 if (argc > 2)
86 last = atoi(argv[2]) + 1;
87 if (argc > 3)
88 fname = argv[3];
89
90 fd = open(fname, 0, 0);
91 fout = fopen("kernel_font.c", "w");
92
93 fprintf(fout, "/* \n\
94 * Mach Operating System\n\
95 * Copyright (c) 1989 Carnegie-Mellon University\n\
96 * All rights reserved. The CMU software License Agreement specifies\n\
97 * the terms and conditions for use and redistribution.\n\
98 */\n\
99 /*\n\
100 * THIS FILE WAS GENERATED BY %s FROM %s\n\
101 * IF YOU NEED TO, BE SURE YOU EDIT THE REAL THING!\n\
102 */\n\
103 /*\n\
104 * HISTORY\n\
105 * 3-Sep-90 Alessandro Forin (af) at Carnegie-Mellon University\n\
106 * Created.\n\
107 * $Log: build_font.c,v $
108 * Revision 2.6 91/06/19 11:46:19 rvb
109 * File moved here from mips/PMAX since it tries to be generic;
110 * it is used on the PMAX and the Vax3100.
111 * [91/06/04 rvb]
112 *
113 * Revision 2.5.1.1 91/06/06 14:08:04 rvb
114 * File moved here from mips/PMAX since it tries to be generic;
115 * it is used on the PMAX and the Vax3100.
116 * [91/06/04 rvb]
117 *
118 * Revision 2.5 91/05/14 17:19:54 mrt
119 * Correcting copyright
120 *
121 * Revision 2.4 91/02/05 17:40:00 mrt
122 * Added author notices
123 * [91/02/04 11:12:16 mrt]
124 *
125 * Changed to use new Mach copyright
126 * [91/02/02 12:09:59 mrt]
127 *
128 * Revision 2.3.1.2 91/02/04 11:12:16 mrt
129 * Added author notices
130 *
131 * Revision 2.3.1.1 91/02/02 12:09:59 mrt
132 * Changed to use new Mach copyright
133 *
134 * Revision 2.3 90/12/05 23:30:32 af
135 * Add Log entry to output file so that it can be RCS-ed.
136 * [90/12/03 23:11:04 af]
137 *
138 * Revision 2.1.2.1 90/12/03 23:11:04 af
139 * Add Log entry to output file so that it can be RCS-ed.
140 *
141 * Revision 2.1.1.2 90/11/01 03:14:32 af
142 * Add Log entry to output file so that it can be RCS-ed.
143 * \n\
144 */\n\
145 \n\
146 /*\n\
147 * Object:\n\
148 * kfont_7x14 EXPORTED array\n\
149 *\n\
150 * Kernel font for printable ASCII chars\n\
151 *\n\
152 * The smallest index in this array corresponds to a\n\
153 * space. So, we start at 0x20 in the ascii table.\n\
154 * Note that glyphs are mirrored (byteorder, I think)\n\
155 * the commented bitmap shows how they really look like\n\
156 */\n\
157 \n\
158 unsigned char kfont_7x14[] = {\n", argv[0], fname);
159
160 skip_comments:
161 read(fd, buf, 1);
162 if (buf[0] == '#') {
163 do
164 read(fd, buf, 1);
165 while (buf[0] != '\n');
166 goto skip_comments;
167 }
168 lseek(fd, -1, 1); /* put char back */
169
170 /* if must skip some */
171 for (l = 0; l < first; l++)
172 read(fd, buf, 2+(9*15));
173
174 /* scan for real now */
175 for (i = first; i < last; i++) {
176 /* read one full glyph */
177 if (read(fd, buf, 2+(9*15)) < 0)
178 break;
179 if (verbose)
180 printf("Character '%c':\n\t", buf[0]);
181 /* index and char itself in comments */
182 fprintf(fout, "/* %3x '%c' */\n", i, 0x20+i);
183
184 /* encode and mirror each one of the 15 scanlines */
185 for (n = 0; n < 15; n++) {
186 unsigned char cc[8], swap = 0;
187 /* 8 bits per scanline */
188 for (k = 2+(n*9), j = 0; j < 8; k++, j++) {
189 if (verbose)
190 printf("%c", (buf[k] == '1') ? '@' : ' ');
191 swap = ((buf[k] - '') << 7) | (swap >> 1);
192 cc[j] = buf[k];
193 }
194 fprintf(fout,"\t/* %8s */\t%#2x,\n", cc, (unsigned char)swap);
195 if (verbose)
196 printf("\n\t");
197 }
198 }
199 fprintf(fout, "};\n");
200 fclose(fout);
201 }
Cache object: 12d03e01026b1ffa63ef0eb2a2825ebd
|