2 * mktrfn - produce troff font descriptions
4 * Copyright (C) 2012-2013 Ali Gholami Rudi <ali at rudi dot ir>
6 * This program is released under the Modified BSD license.
18 static void otfdump_read(void)
23 char c1
[TOKLEN
], c2
[TOKLEN
];
25 while (scanf("%s", cmd
) == 1) {
26 if (!strcmp("name", cmd
)) {
30 if (!strcmp("char", cmd
)) {
31 scanf("%s width %s", ch
, wid
);
32 trfn_char(ch
, NULL
, atoi(wid
), -1);
34 if (!strcmp("kernpair", cmd
)) {
35 scanf("%s %s width %s", c1
, c2
, wid
);
36 trfn_kern(c1
, c2
, atoi(wid
));
38 if (!strcmp("feature", cmd
)) {
39 scanf("%s substitution %s %s", name
, c1
, c2
);
44 static void afm_read(void)
46 char ch
[TOKLEN
], pos
[TOKLEN
];
47 char c1
[TOKLEN
], c2
[TOKLEN
];
50 while (fgets(ln
, sizeof(ln
), stdin
)) {
53 if (!strncmp("FontName ", ln
, 8)) {
54 sscanf(ln
, "FontName %s", ch
);
58 if (!strncmp("StartCharMetrics", ln
, 16))
61 while (fgets(ln
, sizeof(ln
), stdin
)) {
64 if (!strncmp("EndCharMetrics", ln
, 14))
66 if (sscanf(ln
, "C %s ; WX %s ; N %s", pos
, wid
, ch
) == 3)
67 trfn_char(ch
, pos
, atoi(wid
), -1);
69 while (fgets(ln
, sizeof(ln
), stdin
)) {
72 if (!strncmp("StartKernPairs", ln
, 14))
75 while (fgets(ln
, sizeof(ln
), stdin
)) {
78 if (!strncmp("EndKernPairs", ln
, 12))
80 if (sscanf(ln
, "KPX %s %s %s", c1
, c2
, wid
) == 3)
81 trfn_kern(c1
, c2
, atoi(wid
));
86 "Usage: mktrfn [options] <input >output\n"
88 " -o \tread the output of otfdump for otf and ttf files (default)\n"
89 " -a \tread an AFM file\n"
90 " -s \tspecial font\n"
91 " -p name \toverride font postscript name\n"
92 " -t name \tset font troff name\n"
93 " -r res \tset device resolution (720)\n";
95 int main(int argc
, char *argv
[])
101 for (i
= 1; i
< argc
&& argv
[i
][0] == '-'; i
++) {
102 switch (argv
[i
][1]) {
110 res
= atoi(argv
[i
][2] ? argv
[i
] + 2 : argv
[++i
]);
116 trfn_trfont(argv
[i
][2] ? argv
[i
] + 2 : argv
[++i
]);
119 trfn_psfont(argv
[i
][2] ? argv
[i
] + 2 : argv
[++i
]);