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
));
85 int main(int argc
, char *argv
[])
90 for (i
= 1; i
< argc
&& argv
[i
][0] == '-'; i
++) {
99 res
= atoi(argv
[i
][2] ? argv
[i
] + 2 : argv
[++i
]);
102 trfn_trfont(argv
[i
][2] ? argv
[i
] + 2 : argv
[++i
]);
105 trfn_psfont(argv
[i
][2] ? argv
[i
] + 2 : argv
[++i
]);
108 printf("usage: mktrfn -a -o -t name -p psname\n");