1 /* rotprt.c 4.1 83/04/28 */ 2 /* 3 * Print a rotated font. 4 */ 5 6 #include <stdio.h> 7 #include <vfont.h> 8 #include <sys/types.h> 9 #include <sys/stat.h> 10 11 char *chp; 12 char *sbrk(); 13 14 main(argc,argv) 15 char **argv; 16 { 17 struct header h; 18 struct dispatch d[256]; 19 struct stat stb; 20 off_t tell(); 21 int i,size; 22 23 argc--, argv++; 24 if (argc > 0) { 25 close(0); 26 if (open(argv[0], 0) < 0) 27 perror(argv[0]), exit(1); 28 } 29 if (read(0, &h, sizeof(h)) != sizeof(h)) 30 fprintf(stderr, "header read error\n"), exit(1); 31 if (h.magic != 0436) 32 fprintf(stderr, "bad magic number\n"), exit(1); 33 if (read(0, d, sizeof(d)) != sizeof(d)) 34 fprintf(stderr, "dispatch read error\n"), exit(1); 35 fstat(0, &stb); 36 size = stb.st_size - tell(0); 37 fprintf(stderr, "%d bytes of characters\n", size); 38 chp = sbrk(size); 39 read(0, chp, size); 40 /* write(1, &h, sizeof (h)); */ 41 for (i = 0; i < 256; i++) 42 rprt(i, &d[i], chp+d[i].addr); 43 } 44 45 rprt(i, dp, cp) 46 int i; 47 struct dispatch *dp; 48 char *cp; 49 { 50 int bpl, j; 51 52 if (dp->nbytes == 0) 53 return; 54 if (i >= 0200) 55 printf("M-"), i -= 0200; 56 if (i < 040) 57 printf("^%c", i|'@'); 58 else if (i == 0177) 59 printf("^?"); 60 else 61 printf("%c", i); 62 printf("%d bytes, l %d r %d u %d d %d:\n", 63 dp->nbytes, dp->left, dp->right, dp->up, dp->down); 64 bpl = (dp->up+dp->down+7)/8; 65 for (i = 0; i < dp->right+dp->left; i++) { 66 for (j = 0; j < bpl; j++) 67 pbits(cp[j]); 68 cp += bpl; 69 printf("\n"); 70 } 71 printf("========\n"); 72 } 73 74 pbits(i) 75 register int i; 76 { 77 register int j; 78 79 for (j = 8; j > 0; j--) { 80 printf((i & 0x80) ? " *" : " "); 81 i <<= 1; 82 } 83 } 84