|
|
1.1 root 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 [email protected]
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: * File: build_font.c
28: * Author: Alessandro Forin, Carnegie Mellon University
29: * Date: 10/90
30: *
31: *
32: * Takes a font description file and generates a C source
33: * appropriate for use as kernel font on mips/vax boxes.
34: * This basically means encoding and mirroring the bitmaps.
35: */
36:
37: #include <stdio.h>
38:
39: main(argc,argv)
40: char **argv;
41: {
42: int fd;
43: FILE *fout;
44: int i, j, k, n, l;
45: int first, last;
46: char *fname = "kernel_font.data";
47: char buf[16*9];
48: int verbose = 0;
49:
50: if (argc > 1 && argv[1][0] == '+')
51: verbose++, argc--, argv++;
52:
53: first = 0;
54: last = 190; /* 8-bit ASCII, offset by 'space' */
55: if (argc > 1) {
56: first = atoi(argv[1]);
57: last = first + 1;
58: }
59: if (argc > 2)
60: last = atoi(argv[2]) + 1;
61: if (argc > 3)
62: fname = argv[3];
63:
64: fd = open(fname, 0, 0);
65: fout = fopen("kernel_font.c", "w");
66:
67: fprintf(fout, "/* \n\
68: * Mach Operating System\n\
69: * Copyright (c) 1989 Carnegie-Mellon University\n\
70: * All rights reserved. The CMU software License Agreement specifies\n\
71: * the terms and conditions for use and redistribution.\n\
72: */\n\
73: /*\n\
74: * THIS FILE WAS GENERATED BY %s FROM %s\n\
75: * IF YOU NEED TO, BE SURE YOU EDIT THE REAL THING!\n\
76: */\n\
77: /*\n\
78: * Object:\n\
79: * kfont_7x14 EXPORTED array\n\
80: *\n\
81: * Kernel font for printable ASCII chars\n\
82: *\n\
83: * The smallest index in this array corresponds to a\n\
84: * space. So, we start at 0x20 in the ascii table.\n\
85: * Note that glyphs are mirrored (byteorder, I think)\n\
86: * the commented bitmap shows how they really look like\n\
87: */\n\
88: \n\
89: unsigned char kfont_7x14[] = {\n", argv[0], fname);
90:
91: skip_comments:
92: read(fd, buf, 1);
93: if (buf[0] == '#') {
94: do
95: read(fd, buf, 1);
96: while (buf[0] != '\n');
97: goto skip_comments;
98: }
99: lseek(fd, -1, 1); /* put char back */
100:
101: /* if must skip some */
102: for (l = 0; l < first; l++)
103: read(fd, buf, 2+(9*15));
104:
105: /* scan for real now */
106: for (i = first; i < last; i++) {
107: /* read one full glyph */
108: if (read(fd, buf, 2+(9*15)) < 0)
109: break;
110: if (verbose)
111: printf("Character '%c':\n\t", buf[0]);
112: /* index and char itself in comments */
113: fprintf(fout, "/* %3x '%c' */\n", i, 0x20+i);
114:
115: /* encode and mirror each one of the 15 scanlines */
116: for (n = 0; n < 15; n++) {
117: unsigned char cc[8], swap = 0;
118: /* 8 bits per scanline */
119: for (k = 2+(n*9), j = 0; j < 8; k++, j++) {
120: if (verbose)
121: printf("%c", (buf[k] == '1') ? '@' : ' ');
122: swap = ((buf[k] - '0') << 7) | (swap >> 1);
123: cc[j] = buf[k];
124: }
125: fprintf(fout,"\t/* %8s */\t%#2x,\n", cc, (unsigned char)swap);
126: if (verbose)
127: printf("\n\t");
128: }
129: }
130: fprintf(fout, "};\n");
131: fclose(fout);
132: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.