2 * NEATMKFN - GENERATE NEATROFF FONT DESCRIPTIONS
4 * Copyright (C) 2012-2018 Ali Gholami Rudi <ali at rudi dot ir>
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 #define LEN(a) ((sizeof(a) / sizeof((a)[0])))
25 static char *trfn_scripts
; /* filtered scripts */
26 static char *trfn_langs
; /* filtered languages */
28 /* OpenType specifies a specific feature order for different scripts */
29 static char *scriptorder
[][2] = {
30 {"latn", "ccmp,liga,clig,dist,kern,mark,mkmk"},
31 {"cyrl", "ccmp,liga,clig,dist,kern,mark,mkmk"},
32 {"grek", "ccmp,liga,clig,dist,kern,mark,mkmk"},
33 {"armn", "ccmp,liga,clig,dist,kern,mark,mkmk"},
34 {"geor", "ccmp,liga,clig,dist,kern,mark,mkmk"},
35 {"runr", "ccmp,liga,clig,dist,kern,mark,mkmk"},
36 {"ogam", "ccmp,liga,clig,dist,kern,mark,mkmk"},
37 {"arab", "ccmp,isol,fina,medi,init,rlig,calt,liga,dlig,cswh,mset,curs,kern,mark,mkmk"},
38 {"bugi", "locl,ccmp,rlig,liga,clig,calt,kern,dist,mark,mkmk"},
39 {"hang", "ccmp,ljmo,vjmo,tjmo"},
40 {"hebr", "ccmp,dlig,kern,mark"},
41 {"bng2", "locl,nukt,akhn,rphf,blwf,half,pstf,vatu,cjct,init,pres,abvs,blws,psts,haln,calt,kern,dist,abvm,blwm"},
42 {"dev2", "locl,nukt,akhn,rphf,blwf,half,pstf,vatu,cjct,init,pres,abvs,blws,psts,haln,calt,kern,dist,abvm,blwm"},
43 {"gjr2", "locl,nukt,akhn,rphf,blwf,half,pstf,vatu,cjct,init,pres,abvs,blws,psts,haln,calt,kern,dist,abvm,blwm"},
44 {"gur2", "locl,nukt,akhn,rphf,blwf,half,pstf,vatu,cjct,init,pres,abvs,blws,psts,haln,calt,kern,dist,abvm,blwm"},
45 {"knd2", "locl,nukt,akhn,rphf,blwf,half,pstf,vatu,cjct,init,pres,abvs,blws,psts,haln,calt,kern,dist,abvm,blwm"},
46 {"mlym", "locl,nukt,akhn,rphf,blwf,half,pstf,vatu,cjct,init,pres,abvs,blws,psts,haln,calt,kern,dist,abvm,blwm"},
47 {"ory2", "locl,nukt,akhn,rphf,blwf,half,pstf,vatu,cjct,init,pres,abvs,blws,psts,haln,calt,kern,dist,abvm,blwm"},
48 {"tml2", "locl,nukt,akhn,rphf,blwf,half,pstf,vatu,cjct,init,pres,abvs,blws,psts,haln,calt,kern,dist,abvm,blwm"},
49 {"tml2", "locl,nukt,akhn,rphf,blwf,half,pstf,vatu,cjct,init,pres,abvs,blws,psts,haln,calt,kern,dist,abvm,blwm"},
50 {"telu", "locl,nukt,akhn,rphf,blwf,half,pstf,vatu,cjct,init,pres,abvs,blws,psts,haln,calt,kern,dist,abvm,blwm"},
51 {"java", "locl,pref,abvf,blwf,pstf,pres,abvs,blws,psts,ccmp,rlig,liga,clig,calt,kern,dist,mark,mkmk"},
52 {"khmr", "pref,blwf,abvf,pstf,pres,blws,abvs,psts,clig,dist,blwm,abvm,mkmk"},
53 {"lao ", "ccmp,kern,mark,mkmk"},
54 {"mym2", "locl,rphf,pref,blwf,pstf,pres,abvs,blws,psts,kern,dist,mark,mkmk"},
55 {"sinh", "locl,ccmp,akhn,rphf,vatu,pstf,pres,abvs,blws,psts,kern,dist,abvm,blwm"},
56 {"syrc", "stch,ccmp,isol,fina,fin2,fin3,medi,med2,init,rlig,calt,liga,dlig,kern,mark,mkmk"},
57 {"thaa", "kern,mark"},
58 {"thai", "ccmp,kern,mark,mkmk"},
59 {"tibt", "ccmp,abvs,blws,calt,liga,kern,abvm,blwm,mkmk"},
62 /* return 1 if the given script is to be included */
63 int trfn_script(char *script
, int nscripts
)
65 /* fill trfn_scripts (if unspecified) in the first call */
67 if (nscripts
== 1 || !script
)
69 if (!strcmp("DFLT", script
))
70 trfn_scripts
= "DFLT";
72 trfn_scripts
= "latn";
74 if (!strcmp("help", trfn_scripts
))
75 fprintf(stderr
, "script: %s\n", script
? script
: "");
76 if (strchr(script
, ' '))
77 *strchr(script
, ' ') = '\0';
78 return !!strstr(trfn_scripts
, script
);
81 /* return 1 if the given language is to be included */
82 int trfn_lang(char *lang
, int nlangs
)
88 if (!strcmp("help", trfn_langs
))
89 fprintf(stderr
, "lang: %s\n", lang
);
90 if (strchr(lang
, ' '))
91 *strchr(lang
, ' ') = '\0';
92 return !!strstr(trfn_langs
, lang
);
95 /* return the rank of the given feature, for the current script */
96 int trfn_featrank(char *scrp
, char *feat
)
100 if (!order
|| strcmp(scrp
, order
[0])) {
102 for (i
= 0; i
< LEN(scriptorder
); i
++)
103 if (!strcmp(scrp
, scriptorder
[i
][0]))
104 order
= scriptorder
[i
];
106 if (order
&& strstr(order
[1], feat
))
107 return strstr(order
[1], feat
) - order
[1];
113 void otf_feat(int res
, int kmin
, int warn
);
116 "Usage: mktrfn [options] <input >output\n"
118 " -a \tread an AFM file (default)\n"
119 " -o \tread an OTF file\n"
120 " -s \tspecial font\n"
121 " -p name \toverride font postscript name\n"
122 " -t name \tset font troff name\n"
123 " -f path \tset font path\n"
124 " -r res \tset device resolution (720)\n"
125 " -k kmin \tspecify the minimum amount of kerning (0)\n"
126 " -b \tinclude glyph bounding boxes\n"
127 " -l \tsuppress the ligatures line\n"
128 " -n \tsuppress glyph positions\n"
129 " -S scrs \tcomma-separated list of scripts to include (help to list)\n"
130 " -L langs\tcomma-separated list of languages to include (help to list)\n"
131 " -w \twarn about unsupported font features\n";
133 int main(int argc
, char *argv
[])
144 for (i
= 1; i
< argc
&& argv
[i
][0] == '-'; i
++) {
145 switch (argv
[i
][1]) {
153 trfn_pspath(argv
[i
][2] ? argv
[i
] + 2 : argv
[++i
]);
156 kmin
= atoi(argv
[i
][2] ? argv
[i
] + 2 : argv
[++i
]);
162 trfn_langs
= argv
[i
][2] ? argv
[i
] + 2 : argv
[++i
];
171 trfn_psfont(argv
[i
][2] ? argv
[i
] + 2 : argv
[++i
]);
174 res
= atoi(argv
[i
][2] ? argv
[i
] + 2 : argv
[++i
]);
180 trfn_scripts
= argv
[i
][2] ? argv
[i
] + 2 : argv
[++i
];
183 trfn_trfont(argv
[i
][2] ? argv
[i
] + 2 : argv
[++i
]);
193 trfn_init(res
, spc
, kmin
, bbox
, ligs
, pos
);
200 otf_feat(res
, kmin
, warn
);