1 /* loadfont.c - Load custom font into EGA, VGA video card
3 * Author: Hrvoje Stipetic (hs@hck.hr) Jun-1995.
14 #include <sys/ioctl.h>
18 write(2, s
, strlen(s
));
21 char *itoa(unsigned i
)
23 static char a
[3*sizeof(int)];
24 char *p
= a
+sizeof(a
)-1;
28 } while ((i
/= 10) > 0);
33 void report(char *say
)
47 tell("Usage: loadfont fontfile\n");
52 int main(int argc
, char *argv
[])
54 static u8_t font
[256][32];
55 static u8_t font_file
[256 * (16+14+8) + 1];
57 int fd
, size
, tsize
, ch
, ln
;
64 if ((fd
= open(argv
[1], O_RDONLY
)) < 0) {
69 switch (read(fd
, font_file
, sizeof(font_file
))) {
88 tell(": fontfile is not an 8x8, 8x14, 8x16, or compound font\n");
93 if (ioctl(0, TIOCGWINSZ
, &ws
) < 0 || (errno
= ENOTTY
, ws
.ws_row
== 0)) {
97 tsize
= ws
.ws_ypixel
/ ws
.ws_row
;
101 ff
= font_file
+ 256 * (0);
104 ff
= font_file
+ 256 * (16);
106 ff
= font_file
+ 256 * (16 + 14);
113 for (ch
= 0; ch
< 256; ch
++) {
114 for (ln
= 0; ln
< size
; ln
++) font
[ch
][ln
] = ff
[ch
* size
+ ln
];
117 if (ioctl(0, TIOCSFON
, font
) < 0) {