|
|
1.1 ! root 1: static char *sccsid = "@(#)vfontinfo.c 4.1 (Berkeley) 10/1/80"; ! 2: /* Font Information for VCat-style fonts ! 3: * AJH 4/79 ! 4: * ! 5: * Modified to print Ascii chars 1/80 by Mark Horton ! 6: */ ! 7: #include <stdio.h> ! 8: #include <ctype.h> ! 9: #include <vfont.h> ! 10: ! 11: struct header FontHeader; ! 12: struct dispatch disptable[256] ; ! 13: ! 14: char IName[100]; ! 15: char * rdchar(); ! 16: long fbase; ! 17: ! 18: char defascii[256]; ! 19: char *charswanted = defascii; ! 20: int verbose; ! 21: char charbits[4000]; ! 22: int H, W, WB; ! 23: ! 24: main(argc,argv) ! 25: int argc; ! 26: char **argv; ! 27: ! 28: { ! 29: int FID,i,j; ! 30: ! 31: if (argc > 1 && argv[1][0] == '-') { ! 32: switch(argv[1][1]) { ! 33: case 'v': ! 34: verbose++; ! 35: break; ! 36: default: ! 37: printf("Bad flag: %s\n", argv[1]); ! 38: } ! 39: argc--; argv++; ! 40: } ! 41: if (argc < 2) { ! 42: fprintf(stderr,"Usage: %s filename", argv[0]); ! 43: exit(2); ! 44: } ! 45: ! 46: for (i=0; i<128; i++) ! 47: defascii[i] = i; ! 48: if (argc >= 3) ! 49: charswanted = argv[2]; ! 50: ! 51: sprintf(IName,"/usr/lib/vfont/%s",argv[1]); ! 52: if ((FID = open(argv[1],0)) < 0) ! 53: if ((FID = open(IName,0)) < 0) { ! 54: printf("Can't find %s\n",argv[1]); ! 55: exit(8); ! 56: }; ! 57: ! 58: if (read(FID,&FontHeader,sizeof FontHeader) != sizeof FontHeader) ! 59: error("Bad header in Font file."); ! 60: ! 61: if (read(FID,&disptable[0],sizeof disptable) != sizeof disptable) ! 62: error("Bad dispatch table in Font file"); ! 63: ! 64: fbase = sizeof FontHeader + sizeof disptable; ! 65: ! 66: if (FontHeader.magic != 0436) ! 67: printf("Magic number %o wrong\n", FontHeader.magic); ! 68: printf("Font %s, ",argv[1]); ! 69: printf("raster size %d, ",FontHeader.size); ! 70: printf("max width %d, max height %d, xtend %d\n", ! 71: FontHeader.maxx, FontHeader.maxy,FontHeader.xtend); ! 72: printf("\n ASCII offset size left right up down width \n"); ! 73: ! 74: for (i=0; i<256; i++) { ! 75: j = charswanted[i]; ! 76: if (i>0 && j==0) ! 77: break; ! 78: if (disptable[j].nbytes != 0) { ! 79: printf(" %3o %2s %4d %4d %4d %4d %4d %4d %5d\n", ! 80: j, rdchar(j), ! 81: disptable[j].addr, ! 82: disptable[j].nbytes, ! 83: disptable[j].left, ! 84: disptable[j].right, ! 85: disptable[j].up, ! 86: disptable[j].down, ! 87: disptable[j].width); ! 88: if (verbose) { ! 89: int len = disptable[j].nbytes; ! 90: int k, l, last; ! 91: ! 92: lseek(FID, fbase+disptable[j].addr, 0); ! 93: read(FID, charbits, len); ! 94: H = (disptable[j].up) + (disptable[j].down); ! 95: W = (disptable[j].left) + (disptable[j].right); ! 96: WB = (W+7)/8; ! 97: for (k=0; k<H; k++) { ! 98: for (last=W-1; last >= 0; last--) ! 99: if (fbit(k, last)) ! 100: break; ! 101: for (l=0; l<=last; l++) { ! 102: printf("%c", fbit(k,l)?'M':' '); ! 103: } ! 104: printf("\n"); ! 105: } ! 106: printf("\n"); ! 107: } ! 108: } ! 109: }; ! 110: } ! 111: ! 112: error(string) ! 113: char *string; ! 114: ! 115: { ! 116: printf("\nvfontinfo: %s\n",string); ! 117: exit(8); ! 118: }; ! 119: ! 120: char *rdchar(c) ! 121: char c; ! 122: { ! 123: static char ret[3]; ! 124: ret[0] = isprint(c) ? ' ' : '^'; ! 125: ret[1] = isprint(c) ? c : c^0100; ! 126: ret[2] = 0; ! 127: return (ret); ! 128: } ! 129: ! 130: int ! 131: fbit(row, col) ! 132: int row, col; ! 133: { ! 134: int thisbyte, thisbit, ret; ! 135: ! 136: thisbyte = charbits[row*WB + (col>>3)] & 0xff; ! 137: thisbit = 0x80 >> (col&7); ! 138: ret = thisbyte & thisbit; ! 139: return (ret != 0); ! 140: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.