4 #include <sys/consio.h>
5 #include <sys/endian.h>
20 uint32_t map_count[4];
24 load_mappingtable(unsigned int nmappings)
32 t = malloc(sizeof *t * nmappings);
34 if (fread(t, sizeof *t * nmappings, 1, stdin) != 1) {
39 for (i = 0; i < nmappings; i++) {
40 t[i].src = be32toh(t[i].src);
41 t[i].dst = be16toh(t[i].dst);
42 t[i].len = be16toh(t[i].len);
49 main(int argc __unused, char *argv[] __unused)
51 struct file_header fh;
56 if (fread(&fh, sizeof fh, 1, stdin) != 1) {
57 perror("file_header");
61 if (memcmp(fh.magic, "VFNT0002", 8) != 0) {
62 fprintf(stderr, "Bad magic\n");
66 for (i = 0; i < VFNT_MAPS; i++)
67 vfnt.map_count[i] = be32toh(fh.map_count[i]);
68 vfnt.glyph_count = be32toh(fh.glyph_count);
69 vfnt.width = fh.width;
70 vfnt.height = fh.height;
72 glyphsize = howmany(vfnt.width, 8) * vfnt.height * vfnt.glyph_count;
73 vfnt.glyphs = malloc(glyphsize);
75 if (fread(vfnt.glyphs, glyphsize, 1, stdin) != 1) {
80 for (i = 0; i < VFNT_MAPS; i++)
81 vfnt.map[i] = load_mappingtable(vfnt.map_count[i]);
83 if (ioctl(STDOUT_FILENO, PIO_VFONT, &vfnt) == -1) {