1 #include <sys/consio.h>
2 #include <sys/endian.h>
16 uint16_t nmappings_normal;
17 uint16_t nmappings_bold;
21 load_mappingtable(unsigned int nmappings)
29 t = malloc(sizeof *t * nmappings);
31 if (fread(t, sizeof *t * nmappings, 1, stdin) != 1) {
36 for (i = 0; i < nmappings; i++) {
37 t[i].src = be32toh(t[i].src);
38 t[i].dst = be16toh(t[i].dst);
39 t[i].len = be16toh(t[i].len);
46 main(int argc __unused, char *argv[] __unused)
48 struct file_header fh;
52 if (fread(&fh, sizeof fh, 1, stdin) != 1) {
53 perror("file_header");
57 if (memcmp(fh.magic, "VFNT 1.0", 8) != 0) {
58 fprintf(stderr, "Bad magic\n");
62 vfnt.nnormal = be16toh(fh.nmappings_normal);
63 vfnt.nbold = be16toh(fh.nmappings_bold);
64 vfnt.nglyphs = be16toh(fh.nglyphs);
65 vfnt.width = fh.width;
66 vfnt.height = fh.height;
68 glyphsize = howmany(vfnt.width, 8) * vfnt.height * vfnt.nglyphs;
69 vfnt.glyphs = malloc(glyphsize);
71 if (fread(vfnt.glyphs, glyphsize, 1, stdin) != 1) {
76 vfnt.normal = load_mappingtable(vfnt.nnormal);
77 vfnt.bold = load_mappingtable(vfnt.nbold);
79 if (ioctl(STDOUT_FILENO, PIO_VFONT, &vfnt) == -1) {