xref: /csrg-svn/old/roff/troff_font/mkfont.c (revision 48308)
1*48308Sbostic /*-
2*48308Sbostic  * %sccs.include.proprietary.c%
3*48308Sbostic  */
4*48308Sbostic 
57110Srrh #ifndef lint
6*48308Sbostic static char sccsid[] = "@(#)mkfont.c	4.4 (Berkeley) 04/18/91";
7*48308Sbostic #endif /* not lint */
87110Srrh 
97110Srrh #include "mkfont1.c"
107110Srrh 
117110Srrh /*
127110Srrh   this program takes 102 width values
137110Srrh   (one per line) in the order provided bu Graphic
147110Srrh   Systems and prepares a C-compileable width table.
157110Srrh */
167110Srrh char ibuf[512];
177110Srrh int id;
187110Srrh int width[102];
197110Srrh int ascii[102];
207110Srrh int zero;
217110Srrh int emw, hyw;
227110Srrh int xxx;
237110Srrh 
main(argc,argv)247110Srrh main(argc,argv)
257110Srrh int argc;
267110Srrh char **argv;
277110Srrh {
287110Srrh 	register i, j;
297110Srrh 	register char *p;
307110Srrh 
317110Srrh 	while((--argc > 0) && ((++argv)[0][0]=='-')){
327110Srrh 		switch(argv[0][1]){
337110Srrh 			default:
347110Srrh 				continue;
357110Srrh 		}
367110Srrh 	}
377110Srrh 	if(argc){
387110Srrh 		if((id=open(argv[0],0)) < 0){
397110Srrh 			printf("Cannot open: %s.\n",argv[0]);
407110Srrh 			exit(1);
417110Srrh 		}
427110Srrh 	}
437110Srrh 	j = read(id,ibuf,512);
447110Srrh 	p = ibuf;
457110Srrh 	for(i=0; i<102; i++){
467110Srrh 		width[i] = atoi(p);
477110Srrh 		while(*p++ != '\n');
487110Srrh 	}
497110Srrh 	for(i=0; i<102; i++){
507110Srrh 		if(font[i].name < 0177){
517110Srrh 			ascii[i] = font[i].name;
527110Srrh 		}else{
5332130Sbostic 			for(j=0; chtab[j] != 0; j += 2){
547110Srrh 				if(font[i].name == chtab[j])break;
557110Srrh 			}
567110Srrh 			ascii[i] = chtab[j+1] & 0377;
5733484Sbostic 			if(chtab[j] == PAIR('h','y')) hyw = width[i];
5833484Sbostic 			if(chtab[j] == PAIR('e','m')) emw = width[i];
597110Srrh 		}
607110Srrh 	}
617110Srrh 	printf("char XXw[256-32] {\t/*XX*/\n");
627110Srrh 	for(i=040; i<256; i++){
637110Srrh 		if(i == 0377){
647110Srrh 			printf("0};\n");
657110Srrh 			break;
667110Srrh 		}
677110Srrh 		if(i == 0177){
687110Srrh 			printf("6,\t %s\n",nametab[i-040]);
697110Srrh 			continue;
707110Srrh 		}
717110Srrh 		if(i == 0226){
727110Srrh 			printf("3,\t %s\n",nametab[i-040]);
737110Srrh 			continue;
747110Srrh 		}
757110Srrh 		if(i == ' '){
767110Srrh 			printf("12,\t %s\n",nametab[i-040]);
777110Srrh 			continue;
787110Srrh 		}
797110Srrh 		if(i == '-'){
807110Srrh 			printf("%d,\t %s\n",hyw,nametab[i-040]);
817110Srrh 			continue;
827110Srrh 		}
837110Srrh 		for(j=0; j<102; j++){
847110Srrh 			if(ascii[j] == i)break;
857110Srrh 		}
867110Srrh 		if(j == 102){
877110Srrh 			printf("0,");
887110Srrh 			zero++;
897110Srrh 			if(nametab[i-040]){
907110Srrh 				printf("\t %s\n",nametab[i-040]);
917110Srrh 				zero = 0;
927110Srrh 			}else if(i < 0177){
937110Srrh 				printf("\t /*%c*/\n",i);
947110Srrh 				zero = 0;
957110Srrh 			}
967110Srrh 			if(zero && !((i+1)%8)){
977110Srrh 				printf("\n");
987110Srrh 				zero = 0;
997110Srrh 			}
1007110Srrh 		}else{
1017110Srrh 			if(zero){
1027110Srrh 				zero = 0;
1037110Srrh 				printf("\n");
1047110Srrh 			}
1057110Srrh 			printf("%d",width[j]);
1067110Srrh 			if(font[j].ctval)printf("+0%d00, ",font[j].ctval);
1077110Srrh 			else printf(",\t ");
1087110Srrh 			printf("%s\n",nametab[i-040]);
1097110Srrh 		}
1107110Srrh 	}
1117110Srrh }
112