/* * dega2vga - convert a Degas font (from the Atari ST) to a VGA 8x16 font * suitable for IBM-PC applications. */ #include #include #include #include #include "glob.h" char thefont[2048]; char template[2048]; char controls[16*32]; convertfont(file) char *file; { char bfr[200]; char *p; char *ext; int ifd, ofd; /* open the raw file and get the low 128 characters out of the font. */ if ((ifd = open(file, O_RDONLY|O_BINARY)) < 0) { perror(file); return 0; } if (read(ifd, thefont, 2048) != 2048) { perror(file); close(ifd); return 0; } close(ifd); /* make a .f16 filename to hold the output vga font */ strcpy(bfr, file); p = basename(bfr); if (ext = strrchr(p, '.')) { if (strcmp(ext, ".f16") == 0) { fprintf(stderr, "%s is already converted\n", file); return 0; } *ext = 0; } memcpy(thefont, controls, 32*16); strcat(bfr, ".f16"); /* open the output file and convert away */ if ((ofd = open(bfr, O_WRONLY|O_TRUNC|O_CREAT|O_BINARY)) < 0) { perror(bfr); return 0; } if (write(ofd, thefont, 2048) != 2048 || write(ofd, template, 2048) != 2048) { perror(bfr); close(ofd); remove(bfr); return 0; } close(ofd); printf("%s -> %s\n", file, bfr); return 1; } /* convertfile */ main(argc, argv) char **argv; { char *p; char bfr[200]; int tfd; int i; if (argc < 3) { fprintf(stderr, "usage: dega2vga template_font font [...]\n"); exit(1); } if ((tfd=open(argv[1], O_RDONLY|O_BINARY)) < 0) { sprintf(bfr, "%s.f16", argv[1]); if ((tfd=open(bfr, O_RDONLY|O_BINARY)) < 0) { perror(argv[1]); exit(2); } } if (read(tfd, controls, 32*16) != 32*16) { perror(argv[1]); exit(4); } if (lseek(tfd, 2048L, SEEK_SET) != 2048L) { perror(argv[1]); exit(3); } if (read(tfd, template, 2048) != 2048) { perror(argv[1]); exit(4); } close(tfd); for (i=2; i