#include typedef unsigned char byte; byte str2bin(char str[]) { int i; byte b=0; for(i=0;i<8;i++) if (str[i]=='*') b= (b << 1) | 1; else b= (b << 1); return b; } void main(int argc, char * argv[]) { int i,j; char str[200]; FILE *f; if ( argc != 2) { fprintf(stderr,"Usage: %s fontfile.glyph\n",argv[0] ); exit(-1); } else if( (f=fopen(argv[1],"rb")) == NULL) { fprintf(stderr,"Cann't open file \"%s\"", argv[1]); exit(-1); } for(j=0;(j<256) && (!feof(f)) ;j++) { fgets(str,200,f); if (str[0]!='=') { fprintf(stderr,"Error: Char describtion expected line: %i\n", j); exit(1); } for(i=0;(i<16) && (!feof(f));i++) { fgets(str,200,f); printf("%c", str2bin(str) ); } if (i!=16) fprintf(stderr,"Error: Unecpected end of file.\n"); } if (j!=256) { fprintf(stderr,"Error: Uncomplete font table, ends on char %i",j); } fclose(f); }