14 fprint(2, "usage: afm2troff [-h] [-o offset] [file...]\n");
19 main(int argc, char **argv)
29 offset = atoi(EARGF(usage()));
35 Binit(&bout, 1, OWRITE);
39 for(i=0; i<argc; i++){
40 if((fd = open(argv[i], OREAD)) < 0)
41 sysfatal("open %s: %r", argv[i]);
49 run(char *name, int fd)
52 int nf, code, wid, ad;
58 while((p = Brdline(&b, '\n')) != nil){
59 p[Blinelen(&b)-1] = 0;
64 while(*q == ' ' || *q == '\t')
68 if(strcmp(p, "FontName") == 0 && didname++ == 0)
69 Bprint(&bout, "name %s\n", q);
70 if(strcmp(p, "FullName") == 0 && didfontname++ == 0)
71 Bprint(&bout, "fontname %s\n", q);
72 if(strcmp(p, "C") == 0){
73 nf = getfields(q, f, nelem(f), 1, "\t\r\n\v ");
74 if(nf < 5 || strcmp(f[1], ";") != 0 || strcmp(f[2], "WX") != 0)
76 code = strtol(f[0], 0, 10);
77 wid = strtol(f[3], 0, 10);
83 if(nf < 6 || strcmp(f[nf-6], "B") != 0)
85 if(atoi(f[nf-4]) < -50)
87 if(atoi(f[nf-2]) > 600)
89 if(nf >= 7 && strcmp(f[5], "N") == 0 && strcmp(f[6], "space") == 0)
92 Bprint(&bout, "spacewidth %d\ncharset\n", wid);
94 fmtprint(&fmt, "%C\t%d\t%d\t%d %04x\n",
95 code, wid, ad, code, code);
98 Bprint(&bout, "%s", fmtstrflush(&fmt));