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;
56 while((p = Brdline(&b, '\n')) != nil){
57 p[Blinelen(&b)-1] = 0;
62 while(*q == ' ' || *q == '\t')
66 if(strcmp(p, "FontName") == 0 && didname++ == 0)
67 Bprint(&bout, "name %s\n", q);
68 if(strcmp(p, "FullName") == 0 && didfontname++ == 0)
69 Bprint(&bout, "fontname %s\n", q);
70 if(strcmp(p, "C") == 0){
71 nf = getfields(q, f, nelem(f), 1, "\t\r\n\v ");
72 if(nf < 5 || strcmp(f[1], ";") != 0 || strcmp(f[2], "WX") != 0)
74 code = strtol(f[0], 0, 10);
75 wid = strtol(f[3], 0, 10);
81 if(nf < 6 || strcmp(f[nf-6], "B") != 0)
83 if(atoi(f[nf-4]) < -50)
85 if(atoi(f[nf-2]) > 600)
88 Bprint(&bout, "spacewidth %d\ncharset\n", wid);
90 Bprint(&bout, "%C\t%d\t%d\t%d %04x\n", code, wid, ad, code, code);