otf: pairwise kerning based on glyph classes
[neatmkfn.git] / trfn_ch.h
blob49c41cb45017f8be40e932e286a852bbfc097ba6
1 /* ligatures with unicode aliases */
2 static char *ligs_utf8[][2] = {
3 {"ff", "ff"},
4 {"fi", "fi"},
5 {"fl", "fl"},
6 {"ffi", "ffi"},
7 {"ffl", "ffl"},
8 {"st", "st"},
9 };
10 /* these are not ligatures */
11 static char *ligs_exceptions[] = {
12 "ga", "aq", "ti", "ha",
15 /* AGL exceptions */
16 static char *agl_exceptions[][2] = {
17 {"∆", "Δ"}, /* Delta -> Delatagreek */
18 {"Ω", "Ω"}, /* Omega -> Omegagreek */
19 {"‘", "`"}, /* quoteleft */
20 {"`", "ga"}, /* grave */
21 {"’", "'"}, /* quoteright */
22 {"'", "aq"}, /* quotesingle */
23 {"~", "ti"}, /* asciitilde; using tilde for ~ */
24 {"^", "ha"}, /* asciicircum; using circumflex for ^ */
27 /* troff aliases */
28 static char *alts[][8] = {
29 {"'", "cq"},
30 {"+", "pl"},
31 {"-", "hy"},
32 {"/", "sl"},
33 {"=", "eq"},
34 {"\"", "dq"},
35 {"\\", "bs", "rs"},
36 {"_", "ru", "ul"},
37 {"`", "oq"},
38 {"aq"},
39 {"|", "or"},
40 {"¡", "!!", "r!"},
41 {"¢", "c|", "ct"},
42 {"£", "L-", "ps"},
43 {"¤", "xo", "cr"},
44 {"¥", "Y-", "yn"},
45 {"¦", "||"},
46 {"§", "so", "sc"},
47 {"©", "co"},
48 {"ª", "a_"},
49 {"«", "<<", "Fo"},
50 {"¬", "-,", "no"},
51 {"®", "ro", "rg"},
52 {"°", "0^", "de"},
53 {"±", "+-"},
54 {"²", "2^"},
55 {"³", "3^"},
56 {"µ", "/u"},
57 {"¶", "P!", "pg"},
58 {"·", ".^"},
59 {"¹", "1^"},
60 {"º", "o_"},
61 {"»", ">>", "Fc"},
62 {"¼", "14"},
63 {"½", "12"},
64 {"¾", "34"},
65 {"¿", "??", "r?"},
66 {"À", "A`"},
67 {"Á", "A'"},
68 {"Â", "A^"},
69 {"Ã", "A~"},
70 {"Ä", "A:", "A\""},
71 {"Å", "A*"},
72 {"Æ", "AE"},
73 {"Ç", "C,"},
74 {"È", "E`"},
75 {"É", "E'"},
76 {"Ê", "E^"},
77 {"Ë", "E:"},
78 {"Ì", "I`"},
79 {"Í", "I'"},
80 {"Î", "I^"},
81 {"Ï", "I:"},
82 {"Ð", "D-"},
83 {"Ñ", "N~"},
84 {"Ò", "O`"},
85 {"Ó", "O'"},
86 {"Ô", "O^"},
87 {"Õ", "O~"},
88 {"Ö", "O:"},
89 {"×", "xx", "mu"},
90 {"Ø", "O/"},
91 {"Ù", "U`"},
92 {"Ú", "U'"},
93 {"Û", "U^"},
94 {"Ü", "U:"},
95 {"Ý", "Y'"},
96 {"Þ", "TH"},
97 {"ß", "ss"},
98 {"à", "a`"},
99 {"á", "a'"},
100 {"â", "a^"},
101 {"ã", "a~"},
102 {"ä", "a:"},
103 {"å", "a*"},
104 {"æ", "ae"},
105 {"ç", "c,"},
106 {"è", "e`"},
107 {"é", "e'"},
108 {"ê", "e^"},
109 {"ë", "e:"},
110 {"ì", "i`"},
111 {"í", "i'"},
112 {"î", "i^"},
113 {"ï", "i:"},
114 {"ð", "d-"},
115 {"ñ", "n~"},
116 {"ò", "o`"},
117 {"ó", "o'"},
118 {"ô", "o^"},
119 {"õ", "o~"},
120 {"ö", "o:"},
121 {"÷", "di", "-:"},
122 {"ø", "o/"},
123 {"ù", "u`"},
124 {"ú", "u'"},
125 {"û", "u^"},
126 {"ü", "u:"},
127 {"ý", "y'"},
128 {"þ", "th"},
129 {"ÿ", "y:"},
130 {"Č", "C<"},
131 {"č", "c<"},
132 {"Ď", "D<"},
133 {"ď", "d<"},
134 {"ě", "e<"},
135 {"ň", "n<"},
136 {"Ő", "O\""},
137 {"ő", "o\""},
138 {"Ř", "R<"},
139 {"ř", "r<"},
140 {"Š", "S<"},
141 {"š", "s<"},
142 {"Ť", "T<"},
143 {"ť", "t<"},
144 {"Ů", "U*"},
145 {"ů", "u*"},
146 {"Ű", "U\""},
147 {"ű", "u\""},
148 {"Ÿ", "Y:"},
149 {"Ž", "Z<"},
150 {"ž", "z<"},
151 {"ƒ", "fn",},
152 {"¸", ",,", ",a"},
153 {"´", "aa", "\\'"},
154 {"¯", "-a"},
155 {"¨", "\"\"", ":a"},
156 {"ga", "\\`"},
157 {"ˆ", "^", "^a"},
158 {"ˇ", "va"},
159 {"˘", "Ua"},
160 {"˙", ".a"},
161 {"˚", "oa"},
162 {"˛", "Ca"},
163 {"˝", "\"a"},
164 {"˜", "~"},
165 {"Α", "*A"},
166 {"Β", "*B"},
167 {"Γ", "*G"},
168 {"Ε", "*E"},
169 {"Ζ", "*Z"},
170 {"Η", "*Y"},
171 {"Θ", "*H"},
172 {"Ι", "*I"},
173 {"Κ", "*K"},
174 {"Λ", "*L"},
175 {"Μ", "*M"},
176 {"Ν", "*N"},
177 {"Ξ", "*C"},
178 {"Ο", "*O"},
179 {"Π", "*P"},
180 {"Ρ", "*R"},
181 {"Σ", "*S"},
182 {"Τ", "*T"},
183 {"Υ", "*U"},
184 {"Φ", "*F"},
185 {"Χ", "*X"},
186 {"Ψ", "*Q"},
187 {"Ω", "*W"},
188 {"α", "*a"},
189 {"β", "*b"},
190 {"γ", "*g"},
191 {"δ", "*d"},
192 {"ε", "*e"},
193 {"ζ", "*z"},
194 {"η", "*y"},
195 {"θ", "*h"},
196 {"ι", "*i"},
197 {"κ", "*k"},
198 {"λ", "*l"},
199 {"μ", "*m"},
200 {"ν", "*n"},
201 {"ξ", "*c"},
202 {"ο", "*o"},
203 {"π", "*p"},
204 {"ρ", "*r"},
205 {"ς", "ts"},
206 {"σ", "*s"},
207 {"τ", "*t"},
208 {"υ", "*u"},
209 {"φ", "*f"},
210 {"χ", "*x"},
211 {"ψ", "*q"},
212 {"ω", "*w"},
213 {"–", "en", "\\-"},
214 {"—", "em", "--"},
215 {"‚", "bq"},
216 {"“", "``", "lq"},
217 {"”", "''", "rq"},
218 {"†", "dg"},
219 {"‡", "dd"},
220 {"•", "bu"},
221 {"…", "el"},
222 {"‰", "%0"},
223 {"′", "fm"},
224 {"‹", "fo"},
225 {"›", "fc"},
226 {"⁄", "fr"},
227 {"ℑ", "If"},
228 {"ℛ", "ws"},
229 {"ℜ", "Rf"},
230 {"ℵ", "af"},
231 {"←", "<-"},
232 {"↑", "ua"},
233 {"→", "->"},
234 {"↓", "da"},
235 {"↔", "ab", "<>"},
236 {"↵", "CR"},
237 {"∀", "fa"},
238 {"∂", "pd"},
239 {"∃", "te"},
240 {"∅", "es"},
241 {"∆", "*D"},
242 {"∇", "gr"},
243 {"∈", "mo"},
244 {"∉", "!m"},
245 {"∋", "st"},
246 {"∏", "pr"},
247 {"∑", "su"},
248 {"−", "mi"},
249 {"∓", "-+"},
250 {"∗", "**"},
251 {"√", "sr"},
252 {"∝", "pt"},
253 {"∞", "if"},
254 {"∠", "an"},
255 {"∧", "l&"},
256 {"∨", "l|"},
257 {"∩", "ca"},
258 {"∪", "cu"},
259 {"∫", "is"},
260 {"∴", "tf"},
261 {"∼", "ap"},
262 {"≅", "cg", "=~"},
263 {"≈", "~~"},
264 {"≠", "!="},
265 {"≡", "=="},
266 {"≤", "<="},
267 {"≥", ">="},
268 {"⊂", "sb"},
269 {"⊃", "sp"},
270 {"⊄", "!b"},
271 {"⊆", "ib"},
272 {"⊇", "ip"},
273 {"⊕", "O+"},
274 {"⊗", "Ox"},
275 {"⊥", "pp"},
276 {"⋅", "c."},
277 {"〈", "b<"},
278 {"〉", "b>"},
279 {"◊", "lz"},
280 {"○", "ci"},
281 {"⟨", "la"},
282 {"⟩", "ra"},
283 {"", "co"},
284 {"", "rg"},
285 {"", "tm"},
286 {"", "rn"},
287 {"", "av"},
288 {"", "ah"},
289 {"", "RG"},
290 {"", "CO"},
291 {"", "TM"},
292 {"", "LT"},
293 {"", "br", "LX"},
294 {"", "LB"},
295 {"", "lc"},
296 {"", "lx"},
297 {"", "lf"},
298 {"", "lt"},
299 {"", "lk"},
300 {"", "lb"},
301 {"", "bv", "|",},
302 {"", "RT"},
303 {"", "RX"},
304 {"", "RB"},
305 {"", "rc"},
306 {"", "rx"},
307 {"", "rf"},
308 {"", "rt"},
309 {"", "rk"},
310 {"", "rb"},
311 {"ff", "ff"},
312 {"fi", "fi"},
313 {"fl", "fl"},
314 {"ffi", "ffi", "Fi"},
315 {"ffl", "ffl", "Fl"},
316 {"st", "st"},
319 /* different shapes of arabic and farsi characters */
320 static struct achar {
321 char *name;
322 unsigned c;
323 unsigned s;
324 unsigned i;
325 unsigned m;
326 unsigned f;
327 } achars[] = {
328 {"hamza", 0x0621, 0xfe80},
329 {"alefwithmaddaabove", 0x0622, 0xfe81, 0, 0, 0xfe82},
330 {"alefwithhamzaabove", 0x0623, 0xfe83, 0, 0, 0xfe84},
331 {"wawwithhamzaabove", 0x0624, 0xfe85, 0, 0, 0xfe86},
332 {"alefwithhamzabelow", 0x0625, 0xfe87, 0, 0, 0xfe88},
333 {"yehwithhamzaabove", 0x0626, 0xfe89, 0xfe8b, 0xfe8c, 0xfe8a},
334 {"alef", 0x0627, 0xfe8d, 0, 0, 0xfe8e},
335 {"arabicalef", 0x0627},
336 {"beh", 0x0628, 0xfe8f, 0xfe91, 0xfe92, 0xfe90},
337 {"tehmarbuta", 0x0629, 0xfe93, 0, 0, 0xfe94},
338 {"teh", 0x062a, 0xfe95, 0xfe97, 0xfe98, 0xfe96},
339 {"theh", 0x062b, 0xfe99, 0xfe9b, 0xfe9c, 0xfe9a},
340 {"jeem", 0x062c, 0xfe9d, 0xfe9f, 0xfea0, 0xfe9e},
341 {"hah", 0x062d, 0xfea1, 0xfea3, 0xfea4, 0xfea2},
342 {"khah", 0x062e, 0xfea5, 0xfea7, 0xfea8, 0xfea6},
343 {"dal", 0x062f, 0xfea9, 0, 0, 0xfeaa},
344 {"thal", 0x0630, 0xfeab, 0, 0, 0xfeac},
345 {"reh", 0x0631, 0xfead, 0, 0, 0xfeae},
346 {"zain", 0x0632, 0xfeaf, 0, 0, 0xfeb0},
347 {"seen", 0x0633, 0xfeb1, 0xfeb3, 0xfeb4, 0xfeb2},
348 {"sheen", 0x0634, 0xfeb5, 0xfeb7, 0xfeb8, 0xfeb6},
349 {"sad", 0x0635, 0xfeb9, 0xfebb, 0xfebc, 0xfeba},
350 {"dad", 0x0636, 0xfebd, 0xfebf, 0xfec0, 0xfebe},
351 {"tah", 0x0637, 0xfec1, 0xfec3, 0xfec4, 0xfec2},
352 {"zah", 0x0638, 0xfec5, 0xfec7, 0xfec8, 0xfec6},
353 {"ain", 0x0639, 0xfec9, 0xfecb, 0xfecc, 0xfeca},
354 {"ghain", 0x063a, 0xfecd, 0xfecf, 0xfed0, 0xfece},
355 {"tatweel", 0x0640},
356 {"feh", 0x0641, 0xfed1, 0xfed3, 0xfed4, 0xfed2},
357 {"qaf", 0x0642, 0xfed5, 0xfed7, 0xfed8, 0xfed6},
358 {"kaf", 0x0643, 0xfed9, 0xfedb, 0xfedc, 0xfeda},
359 {"lam", 0x0644, 0xfedd, 0xfedf, 0xfee0, 0xfede},
360 {"meem", 0x0645, 0xfee1, 0xfee3, 0xfee4, 0xfee2},
361 {"noon", 0x0646, 0xfee5, 0xfee7, 0xfee8, 0xfee6},
362 {"heh", 0x0647, 0xfee9, 0xfeeb, 0xfeec, 0xfeea},
363 {"waw", 0x0648, 0xfeed, 0, 0, 0xfeee},
364 {"alefmaksura", 0x0649, 0xfeef, 0, 0, 0xfef0},
365 {"yeh", 0x064a, 0xfef1, 0xfef3, 0xfef4, 0xfef2},
366 {"fathatan", 0x064b, 0xfe70},
367 {"dammatan", 0x064c, 0xfe72},
368 {"kasratan", 0x064d, 0xfe74},
369 {"fatha", 0x064e, 0xfe76, 0, 0xfe77, 0},
370 {"damma", 0x064f, 0xfe78, 0, 0xfe79, 0},
371 {"kasra", 0x0650, 0xfe7a, 0, 0xfe7b, 0},
372 {"shadda", 0x0651, 0xfe7c, 0, 0xfe7c, 0},
373 {"sukun", 0x0652, 0xfe7e, 0, 0xfe7f, 0},
374 {"peh", 0x067e, 0xfb56, 0xfb58, 0xfb59, 0xfb57},
375 {"tcheh", 0x0686, 0xfb7a, 0xfb7c, 0xfb7d, 0xfb7b},
376 {"jeh", 0x0698, 0xfb8a, 0, 0, 0xfb8b},
377 {"keheh", 0x06a9, 0xfb8e, 0xfb90, 0xfb91, 0xfb8f},
378 {"gaf", 0x06af, 0xfb92, 0xfb94, 0xfb95, 0xfb93},
379 {"farsiyeh", 0x06cc, 0xfbfc, 0xfbfe, 0xfbff, 0xfbfd},
380 {"lamwithalef", 0xfefb, 0xfefb, 0, 0, 0xfefc},
381 {"arabiccomma", 0x060c},
382 {"arabicsemicolon", 0x061b},
383 {"arabicquestionmark", 0x061f},
384 {"arabicindicdigitzero", 0x0660},
385 {"arabicindicdigitone", 0x0661},
386 {"arabicindicdigittwo", 0x0662},
387 {"arabicindicdigitthree", 0x0663},
388 {"arabicindicdigitfour", 0x0664},
389 {"arabicindicdigitfive", 0x0665},
390 {"arabicindicdigitsix", 0x0666},
391 {"arabicindicdigitseven", 0x0667},
392 {"arabicindicdigiteight", 0x0668},
393 {"arabicindicdigitnine", 0x0669},
394 {"arabicpercentsign", 0x066a},
395 {"extendedarabicindicdigitzero", 0x06f0},
396 {"extendedarabicindicdigitone", 0x06f1},
397 {"extendedarabicindicdigittwo", 0x06f2},
398 {"extendedarabicindicdigitthree", 0x06f3},
399 {"extendedarabicindicdigitfour", 0x06f4},
400 {"extendedarabicindicdigitfive", 0x06f5},
401 {"extendedarabicindicdigitsix", 0x06f6},
402 {"extendedarabicindicdigitseven", 0x06f7},
403 {"extendedarabicindicdigiteight", 0x06f8},
404 {"extendedarabicindicdigitnine", 0x06f9},
405 {"zeronojoin", 0x200c},
406 {"zerojoin", 0x200d},
409 int ctype_ascii[128] = {
410 ['!'] = 2, ['"'] = 2, ['#'] = 2, ['$'] = 2, ['%'] = 2,
411 ['&'] = 2, ['\''] = 2, ['('] = 3, [')'] = 3, ['*'] = 2,
412 ['+'] = 0, [','] = 1, ['-'] = 0, ['.'] = 0, ['/'] = 2,
413 ['0'] = 2, ['1'] = 2, ['2'] = 2, ['3'] = 2, ['4'] = 2,
414 ['5'] = 2, ['6'] = 2, ['7'] = 2, ['8'] = 2, ['9'] = 2,
415 [':'] = 0, [';'] = 1, ['<'] = 0, ['='] = 0, ['>'] = 0,
416 ['?'] = 2, ['@'] = 3, ['A'] = 2, ['B'] = 2, ['C'] = 2,
417 ['D'] = 2, ['E'] = 2, ['F'] = 2, ['G'] = 2, ['H'] = 2,
418 ['I'] = 2, ['J'] = 3, ['K'] = 2, ['L'] = 2, ['M'] = 2,
419 ['N'] = 2, ['O'] = 2, ['P'] = 2, ['Q'] = 3, ['R'] = 2,
420 ['S'] = 2, ['T'] = 2, ['U'] = 2, ['V'] = 2, ['W'] = 2,
421 ['X'] = 2, ['Y'] = 2, ['Z'] = 2, ['['] = 3, ['\\'] = 2,
422 [']'] = 3, ['^'] = 2, ['_'] = 1, ['a'] = 0, ['b'] = 2,
423 ['c'] = 0, ['d'] = 2, ['e'] = 0, ['f'] = 2, ['g'] = 1,
424 ['h'] = 2, ['i'] = 2, ['j'] = 3, ['k'] = 2, ['l'] = 2,
425 ['m'] = 0, ['n'] = 0, ['o'] = 0, ['p'] = 1, ['q'] = 1,
426 ['r'] = 0, ['s'] = 0, ['t'] = 2, ['u'] = 0, ['v'] = 0,
427 ['w'] = 0, ['x'] = 0, ['y'] = 1, ['z'] = 0, ['{'] = 3,
428 ['|'] = 3, ['}'] = 3, ['~'] = 0,