font-ott.lua /size: 34 Kb    last modification: 2021-10-28 13:50
1if not modules then modules = { } end modules ["font-ott"] = {
2    version   = 1.001,
3    comment   = "companion to font-ini.mkiv",
4    author    = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
5    copyright = "PRAGMA ADE / ConTeXt Development Team",
6    license   = "see context related readme files",
7 -- dataonly  = true,
8}
9
10local type, next, tonumber, tostring, rawget, rawset = type, next, tonumber, tostring, rawget, rawset
11local gsub, lower, format, match, gmatch, find = string.gsub, string.lower, string.format, string.match, string.gmatch, string.find
12local sequenced = table.sequenced
13local is_boolean = string.is_boolean
14
15local setmetatableindex    = table.setmetatableindex
16local setmetatablenewindex = table.setmetatablenewindex
17local allocate             = utilities.storage.allocate
18
19local fonts                = fonts
20local otf                  = fonts.handlers.otf
21local otffeatures          = otf.features
22
23local tables               = otf.tables or { }
24otf.tables                 = tables
25
26local statistics           = otf.statistics or { }
27otf.statistics             = statistics
28
29local scripts = allocate {
30    ["adlm"] = "adlam",
31    ["aghb"] = "caucasian albanian",
32    ["ahom"] = "ahom",
33    ["arab"] = "arabic",
34    ["armi"] = "imperial aramaic",
35    ["armn"] = "armenian",
36    ["avst"] = "avestan",
37    ["bali"] = "balinese",
38    ["bamu"] = "bamum",
39    ["bass"] = "bassa vah",
40    ["batk"] = "batak",
41    ["beng"] = "bengali",
42    ["bhks"] = "bhaiksuki",
43    ["bng2"] = "bengali variant 2",
44    ["bopo"] = "bopomofo",
45    ["brah"] = "brahmi",
46    ["brai"] = "braille",
47    ["bugi"] = "buginese",
48    ["buhd"] = "buhid",
49    ["byzm"] = "byzantine music",
50    ["cakm"] = "chakma",
51    ["cans"] = "canadian syllabics",
52    ["cari"] = "carian",
53    ["cham"] = "cham",
54    ["cher"] = "cherokee",
55    ["copt"] = "coptic",
56    ["cprt"] = "cypriot syllabary",
57    ["cyrl"] = "cyrillic",
58    ["dev2"] = "devanagari variant 2",
59    ["deva"] = "devanagari",
60    ["dogr"] = "dogra",
61    ["dsrt"] = "deseret",
62    ["dupl"] = "duployan",
63    ["egyp"] = "egyptian heiroglyphs",
64    ["elba"] = "elbasan",
65    ["ethi"] = "ethiopic",
66    ["geor"] = "georgian",
67    ["gjr2"] = "gujarati variant 2",
68    ["glag"] = "glagolitic",
69    ["gong"] = "gunjala gondi",
70    ["gonm"] = "masaram gondi",
71    ["goth"] = "gothic",
72    ["gran"] = "grantha",
73    ["grek"] = "greek",
74    ["gujr"] = "gujarati",
75    ["gur2"] = "gurmukhi variant 2",
76    ["guru"] = "gurmukhi",
77    ["hang"] = "hangul",
78    ["hani"] = "cjk ideographic",
79    ["hano"] = "hanunoo",
80    ["hatr"] = "hatran",
81    ["hebr"] = "hebrew",
82    ["hluw"] = "anatolian hieroglyphs",
83    ["hmng"] = "pahawh hmong",
84    ["hung"] = "old hungarian",
85    ["ital"] = "old italic",
86    ["jamo"] = "hangul jamo",
87    ["java"] = "javanese",
88    ["kali"] = "kayah li",
89    ["kana"] = "hiragana and katakana",
90    ["khar"] = "kharosthi",
91    ["khmr"] = "khmer",
92    ["khoj"] = "khojki",
93    ["knd2"] = "kannada variant 2",
94    ["knda"] = "kannada",
95    ["kthi"] = "kaithi",
96    ["lana"] = "tai tham",
97    ["lao" ] = "lao",
98    ["latn"] = "latin",
99    ["lepc"] = "lepcha",
100    ["limb"] = "limbu",
101    ["lina"] = "linear a",
102    ["linb"] = "linear b",
103    ["lisu"] = "lisu",
104    ["lyci"] = "lycian",
105    ["lydi"] = "lydian",
106    ["mahj"] = "mahajani",
107    ["maka"] = "makasar",
108    ["mand"] = "mandaic and mandaean",
109    ["mani"] = "manichaean",
110    ["marc"] = "marchen",
111    ["math"] = "mathematical alphanumeric symbols",
112    ["medf"] = "medefaidrin",
113    ["mend"] = "mende kikakui",
114    ["merc"] = "meroitic cursive",
115    ["mero"] = "meroitic hieroglyphs",
116    ["mlm2"] = "malayalam variant 2",
117    ["mlym"] = "malayalam",
118    ["modi"] = "modi",
119    ["mong"] = "mongolian",
120    ["mroo"] = "mro",
121    ["mtei"] = "meitei Mayek",
122    ["mult"] = "multani",
123    ["musc"] = "musical symbols",
124    ["mym2"] = "myanmar variant 2",
125    ["mymr"] = "myanmar",
126    ["narb"] = "old north arabian",
127    ["nbat"] = "nabataean",
128    ["newa"] = "newa",
129    ["nko" ] = 'n"ko',
130    ["nshu"] = "nüshu",
131    ["ogam"] = "ogham",
132    ["olck"] = "ol chiki",
133    ["orkh"] = "old turkic and orkhon runic",
134    ["ory2"] = "odia variant 2",
135    ["orya"] = "oriya",
136    ["osge"] = "osage",
137    ["osma"] = "osmanya",
138    ["palm"] = "palmyrene",
139    ["pauc"] = "pau cin hau",
140    ["perm"] = "old permic",
141    ["phag"] = "phags-pa",
142    ["phli"] = "inscriptional pahlavi",
143    ["phlp"] = "psalter pahlavi",
144    ["phnx"] = "phoenician",
145    ["plrd"] = "miao",
146    ["prti"] = "inscriptional parthian",
147    ["rjng"] = "rejang",
148    ["rohg"] = "hanifi rohingya",
149    ["runr"] = "runic",
150    ["samr"] = "samaritan",
151    ["sarb"] = "old south arabian",
152    ["saur"] = "saurashtra",
153    ["sgnw"] = "sign writing",
154    ["shaw"] = "shavian",
155    ["shrd"] = "sharada",
156    ["sidd"] = "siddham",
157    ["sind"] = "khudawadi",
158    ["sinh"] = "sinhala",
159    ["sogd"] = "sogdian",
160    ["sogo"] = "old sogdian",
161    ["sora"] = "sora sompeng",
162    ["soyo"] = "soyombo",
163    ["sund"] = "sundanese",
164    ["sylo"] = "syloti nagri",
165    ["syrc"] = "syriac",
166    ["tagb"] = "tagbanwa",
167    ["takr"] = "takri",
168    ["tale"] = "tai le",
169    ["talu"] = "tai lu",
170    ["taml"] = "tamil",
171    ["tang"] = "tangut",
172    ["tavt"] = "tai viet",
173    ["tel2"] = "telugu variant 2",
174    ["telu"] = "telugu",
175    ["tfng"] = "tifinagh",
176    ["tglg"] = "tagalog",
177    ["thaa"] = "thaana",
178    ["thai"] = "thai",
179    ["tibt"] = "tibetan",
180    ["tirh"] = "tirhuta",
181    ["tml2"] = "tamil variant 2",
182    ["ugar"] = "ugaritic cuneiform",
183    ["vai" ] = "vai",
184    ["wara"] = "warang citi",
185    ["xpeo"] = "old persian cuneiform",
186    ["xsux"] = "sumero-akkadian cuneiform",
187    ["yi"  ] = "yi",
188    ["zanb"] = "zanabazar square",
189}
190
191local languages = allocate {
192    ["aba" ] = "abaza",
193    ["abk" ] = "abkhazian",
194    ["ach" ] = "acholi",
195    ["acr" ] = "achi",
196    ["ady" ] = "adyghe",
197    ["afk" ] = "afrikaans",
198    ["afr" ] = "afar",
199    ["agw" ] = "agaw",
200    ["aio" ] = "aiton",
201    ["aka" ] = "akan",
202    ["als" ] = "alsatian",
203    ["alt" ] = "altai",
204    ["amh" ] = "amharic",
205    ["ang" ] = "anglo-saxon",
206    ["apph"] = "phonetic transcription—americanist conventions",
207    ["ara" ] = "arabic",
208    ["arg" ] = "aragonese",
209    ["ari" ] = "aari",
210    ["ark" ] = "rakhine",
211    ["asm" ] = "assamese",
212    ["ast" ] = "asturian",
213    ["ath" ] = "athapaskan",
214    ["avr" ] = "avar",
215    ["awa" ] = "awadhi",
216    ["aym" ] = "aymara",
217    ["azb" ] = "torki",
218    ["aze" ] = "azerbaijani",
219    ["bad" ] = "badaga",
220    ["bad0"] = "banda",
221    ["bag" ] = "baghelkhandi",
222    ["bal" ] = "balkar",
223    ["ban" ] = "balinese",
224    ["bar" ] = "bavarian",
225    ["bau" ] = "baulé",
226    ["bbc" ] = "batak toba",
227    ["bbr" ] = "berber",
228    ["bch" ] = "bench",
229    ["bcr" ] = "bible cree",
230    ["bdy" ] = "bandjalang",
231    ["bel" ] = "belarussian",
232    ["bem" ] = "bemba",
233    ["ben" ] = "bengali",
234    ["bgc" ] = "haryanvi",
235    ["bgq" ] = "bagri",
236    ["bgr" ] = "bulgarian",
237    ["bhi" ] = "bhili",
238    ["bho" ] = "bhojpuri",
239    ["bik" ] = "bikol",
240    ["bil" ] = "bilen",
241    ["bis" ] = "bislama",
242    ["bjj" ] = "kanauji",
243    ["bkf" ] = "blackfoot",
244    ["bli" ] = "baluchi",
245    ["blk" ] = "pa'o karen",
246    ["bln" ] = "balante",
247    ["blt" ] = "balti",
248    ["bmb" ] = "bambara (bamanankan)",
249    ["bml" ] = "bamileke",
250    ["bos" ] = "bosnian",
251    ["bpy" ] = "bishnupriya manipuri",
252    ["bre" ] = "breton",
253    ["brh" ] = "brahui",
254    ["bri" ] = "braj bhasha",
255    ["brm" ] = "burmese",
256    ["brx" ] = "bodo",
257    ["bsh" ] = "bashkir",
258    ["bsk" ] = "burushaski",
259    ["bti" ] = "beti",
260    ["bts" ] = "batak simalungun",
261    ["bug" ] = "bugis",
262    ["byv" ] = "medumba",
263    ["cak" ] = "kaqchikel",
264    ["cat" ] = "catalan",
265    ["cbk" ] = "zamboanga chavacano",
266    ["cchn"] = "chinantec",
267    ["ceb" ] = "cebuano",
268    ["cgg" ] = "chiga",
269    ["cha" ] = "chamorro",
270    ["che" ] = "chechen",
271    ["chg" ] = "chaha gurage",
272    ["chh" ] = "chattisgarhi",
273    ["chi" ] = "chichewa (chewa, nyanja)",
274    ["chk" ] = "chukchi",
275    ["chk0"] = "chuukese",
276    ["cho" ] = "choctaw",
277    ["chp" ] = "chipewyan",
278    ["chr" ] = "cherokee",
279    ["chu" ] = "chuvash",
280    ["chy" ] = "cheyenne",
281    ["cja" ] = "western cham",
282    ["cjm" ] = "eastern cham",
283    ["cmr" ] = "comorian",
284    ["cop" ] = "coptic",
285    ["cor" ] = "cornish",
286    ["cos" ] = "corsican",
287    ["cpp" ] = "creoles",
288    ["cre" ] = "cree",
289    ["crr" ] = "carrier",
290    ["crt" ] = "crimean tatar",
291    ["csb" ] = "kashubian",
292    ["csl" ] = "church slavonic",
293    ["csy" ] = "czech",
294    ["ctg" ] = "chittagonian",
295    ["cuk" ] = "san blas kuna",
296    ["dan" ] = "danish",
297    ["dar" ] = "dargwa",
298    ["dax" ] = "dayi",
299    ["dcr" ] = "woods cree",
300    ["deu" ] = "german",
301    ["dgo" ] = "dogri",
302    ["dgr" ] = "dogri",
303    ["dhg" ] = "dhangu",
304    ["dhv" ] = "divehi (dhivehi, maldivian)",
305    ["diq" ] = "dimli",
306    ["div" ] = "divehi (dhivehi, maldivian)",
307    ["djr" ] = "zarma",
308    ["djr0"] = "djambarrpuyngu",
309    ["dng" ] = "dangme",
310    ["dnj" ] = "dan",
311    ["dnk" ] = "dinka",
312    ["dri" ] = "dari",
313    ["duj" ] = "dhuwal",
314    ["dun" ] = "dungan",
315    ["dzn" ] = "dzongkha",
316    ["ebi" ] = "ebira",
317    ["ecr" ] = "eastern cree",
318    ["edo" ] = "edo",
319    ["efi" ] = "efik",
320    ["ell" ] = "greek",
321    ["emk" ] = "eastern maninkakan",
322    ["eng" ] = "english",
323    ["erz" ] = "erzya",
324    ["esp" ] = "spanish",
325    ["esu" ] = "central yupik",
326    ["eti" ] = "estonian",
327    ["euq" ] = "basque",
328    ["evk" ] = "evenki",
329    ["evn" ] = "even",
330    ["ewe" ] = "ewe",
331    ["fan" ] = "french antillean",
332    ["fan0"] = " fang",
333    ["far" ] = "persian",
334    ["fat" ] = "fanti",
335    ["fin" ] = "finnish",
336    ["fji" ] = "fijian",
337    ["fle" ] = "dutch (flemish)",
338    ["fmp" ] = "fe’fe’",
339    ["fne" ] = "forest nenets",
340    ["fon" ] = "fon",
341    ["fos" ] = "faroese",
342    ["fra" ] = "french",
343    ["frc" ] = "cajun french",
344    ["fri" ] = "frisian",
345    ["frl" ] = "friulian",
346    ["frp" ] = "arpitan",
347    ["fta" ] = "futa",
348    ["ful" ] = "fulah",
349    ["fuv" ] = "nigerian fulfulde",
350    ["gad" ] = "ga",
351    ["gae" ] = "scottish gaelic (gaelic)",
352    ["gag" ] = "gagauz",
353    ["gal" ] = "galician",
354    ["gar" ] = "garshuni",
355    ["gaw" ] = "garhwali",
356    ["gez" ] = "ge'ez",
357    ["gih" ] = "githabul",
358    ["gil" ] = "gilyak",
359    ["gil0"] = "kiribati (gilbertese)",
360    ["gkp" ] = "kpelle (guinea)",
361    ["glk" ] = "gilaki",
362    ["gmz" ] = "gumuz",
363    ["gnn" ] = "gumatj",
364    ["gog" ] = "gogo",
365    ["gon" ] = "gondi",
366    ["grn" ] = "greenlandic",
367    ["gro" ] = "garo",
368    ["gua" ] = "guarani",
369    ["guc" ] = "wayuu",
370    ["guf" ] = "gupapuyngu",
371    ["guj" ] = "gujarati",
372    ["guz" ] = "gusii",
373    ["hai" ] = "haitian (haitian creole)",
374    ["hal" ] = "halam",
375    ["har" ] = "harauti",
376    ["hau" ] = "hausa",
377    ["haw" ] = "hawaiian",
378    ["hay" ] = "haya",
379    ["haz" ] = "hazaragi",
380    ["hbn" ] = "hammer-banna",
381    ["her" ] = "herero",
382    ["hil" ] = "hiligaynon",
383    ["hin" ] = "hindi",
384    ["hma" ] = "high mari",
385    ["hmn" ] = "hmong",
386    ["hmo" ] = "hiri motu",
387    ["hnd" ] = "hindko",
388    ["ho"  ] = "ho",
389    ["hri" ] = "harari",
390    ["hrv" ] = "croatian",
391    ["hun" ] = "hungarian",
392    ["hye" ] = "armenian",
393    ["hye0"] = "armenian east",
394    ["iba" ] = "iban",
395    ["ibb" ] = "ibibio",
396    ["ibo" ] = "igbo",
397    ["ido" ] = "ido",
398    ["ijo" ] = "ijo languages",
399    ["ile" ] = "interlingue",
400    ["ilo" ] = "ilokano",
401    ["ina" ] = "interlingua",
402    ["ind" ] = "indonesian",
403    ["ing" ] = "ingush",
404    ["inu" ] = "inuktitut",
405    ["ipk" ] = "inupiat",
406    ["ipph"] = "phonetic transcription—ipa conventions",
407    ["iri" ] = "irish",
408    ["irt" ] = "irish traditional",
409    ["isl" ] = "icelandic",
410    ["ism" ] = "inari sami",
411    ["ita" ] = "italian",
412    ["iwr" ] = "hebrew",
413    ["jam" ] = "jamaican creole",
414    ["jan" ] = "japanese",
415    ["jav" ] = "javanese",
416    ["jbo" ] = "lojban",
417    ["jct" ] = "krymchak",
418    ["jii" ] = "yiddish",
419    ["jud" ] = "ladino",
420    ["jul" ] = "jula",
421    ["kab" ] = "kabardian",
422    ["kab0"] = "kabyle",
423    ["kac" ] = "kachchi",
424    ["kal" ] = "kalenjin",
425    ["kan" ] = "kannada",
426    ["kar" ] = "karachay",
427    ["kat" ] = "georgian",
428    ["kaz" ] = "kazakh",
429    ["kde" ] = "makonde",
430    ["kea" ] = "kabuverdianu (crioulo)",
431    ["keb" ] = "kebena",
432    ["kek" ] = "kekchi",
433    ["kge" ] = "khutsuri georgian",
434    ["kha" ] = "khakass",
435    ["khk" ] = "khanty-kazim",
436    ["khm" ] = "khmer",
437    ["khs" ] = "khanty-shurishkar",
438    ["kht" ] = "khamti shan",
439    ["khv" ] = "khanty-vakhi",
440    ["khw" ] = "khowar",
441    ["kik" ] = "kikuyu (gikuyu)",
442    ["kir" ] = "kirghiz (kyrgyz)",
443    ["kis" ] = "kisii",
444    ["kiu" ] = "kirmanjki",
445    ["kjd" ] = "southern kiwai",
446    ["kjp" ] = "eastern pwo karen",
447    ["kjz" ] = "bumthangkha",
448    ["kkn" ] = "kokni",
449    ["klm" ] = "kalmyk",
450    ["kmb" ] = "kamba",
451    ["kmn" ] = "kumaoni",
452    ["kmo" ] = "komo",
453    ["kms" ] = "komso",
454    ["kmz" ] = "khorasani turkic",
455    ["knr" ] = "kanuri",
456    ["kod" ] = "kodagu",
457    ["koh" ] = "korean old hangul",
458    ["kok" ] = "konkani",
459    ["kom" ] = "komi",
460    ["kon" ] = "kikongo",
461    ["kon0"] = "kongo",
462    ["kop" ] = "komi-permyak",
463    ["kor" ] = "korean",
464    ["kos" ] = "kosraean",
465    ["koz" ] = "komi-zyrian",
466    ["kpl" ] = "kpelle",
467    ["kri" ] = "krio",
468    ["krk" ] = "karakalpak",
469    ["krl" ] = "karelian",
470    ["krm" ] = "karaim",
471    ["krn" ] = "karen",
472    ["krt" ] = "koorete",
473    ["ksh" ] = "kashmiri",
474    ["ksh0"] = "ripuarian",
475    ["ksi" ] = "khasi",
476    ["ksm" ] = "kildin sami",
477    ["ksw" ] = "s’gaw karen",
478    ["kua" ] = "kuanyama",
479    ["kui" ] = "kui",
480    ["kul" ] = "kulvi",
481    ["kum" ] = "kumyk",
482    ["kur" ] = "kurdish",
483    ["kuu" ] = "kurukh",
484    ["kuy" ] = "kuy",
485    ["kyk" ] = "koryak",
486    ["kyu" ] = "western kayah",
487    ["lad" ] = "ladin",
488    ["lah" ] = "lahuli",
489    ["lak" ] = "lak",
490    ["lam" ] = "lambani",
491    ["lao" ] = "lao",
492    ["lat" ] = "latin",
493    ["laz" ] = "laz",
494    ["lcr" ] = "l-cree",
495    ["ldk" ] = "ladakhi",
496    ["lez" ] = "lezgi",
497    ["lij" ] = "ligurian",
498    ["lim" ] = "limburgish",
499    ["lin" ] = "lingala",
500    ["lis" ] = "lisu",
501    ["ljp" ] = "lampung",
502    ["lki" ] = "laki",
503    ["lma" ] = "low mari",
504    ["lmb" ] = "limbu",
505    ["lmo" ] = "lombard",
506    ["lmw" ] = "lomwe",
507    ["lom" ] = "loma",
508    ["lrc" ] = "luri",
509    ["lsb" ] = "lower sorbian",
510    ["lsm" ] = "lule sami",
511    ["lth" ] = "lithuanian",
512    ["ltz" ] = "luxembourgish",
513    ["lua" ] = "luba-lulua",
514    ["lub" ] = "luba-katanga",
515    ["lug" ] = "ganda",
516    ["luh" ] = "luyia",
517    ["luo" ] = "luo",
518    ["lvi" ] = "latvian",
519    ["mad" ] = "madura",
520    ["mag" ] = "magahi",
521    ["mah" ] = "marshallese",
522    ["maj" ] = "majang",
523    ["mak" ] = "makhuwa",
524    ["mal" ] = "malayalam reformed",
525    ["mam" ] = "mam",
526    ["man" ] = "mansi",
527    ["map" ] = "mapudungun",
528    ["mar" ] = "marathi",
529    ["maw" ] = "marwari",
530    ["mbn" ] = "mbundu",
531    ["mbo" ] = "mbo",
532    ["mch" ] = "manchu",
533    ["mcr" ] = "moose cree",
534    ["mde" ] = "mende",
535    ["mdr" ] = "mandar",
536    ["men" ] = "me'en",
537    ["mer" ] = "meru",
538    ["mfa" ] = "pattani malay",
539    ["mfe" ] = "morisyen",
540    ["min" ] = "minangkabau",
541    ["miz" ] = "mizo",
542    ["mkd" ] = "macedonian",
543    ["mkr" ] = "makasar",
544    ["mkw" ] = "kituba",
545    ["mle" ] = "male",
546    ["mlg" ] = "malagasy",
547    ["mln" ] = "malinke",
548    ["mlr" ] = "malayalam reformed",
549    ["mly" ] = "malay",
550    ["mnd" ] = "mandinka",
551    ["mng" ] = "mongolian",
552    ["mni" ] = "manipuri",
553    ["mnk" ] = "maninka",
554    ["mnx" ] = "manx",
555    ["moh" ] = "mohawk",
556    ["mok" ] = "moksha",
557    ["mol" ] = "moldavian",
558    ["mon" ] = "mon",
559    ["mor" ] = "moroccan",
560    ["mos" ] = "mossi",
561    ["mri" ] = "maori",
562    ["mth" ] = "maithili",
563    ["mts" ] = "maltese",
564    ["mun" ] = "mundari",
565    ["mus" ] = "muscogee",
566    ["mwl" ] = "mirandese",
567    ["mww" ] = "hmong daw",
568    ["myn" ] = "mayan",
569    ["mzn" ] = "mazanderani",
570    ["nag" ] = "naga-assamese",
571    ["nah" ] = "nahuatl",
572    ["nan" ] = "nanai",
573    ["nap" ] = "neapolitan",
574    ["nas" ] = "naskapi",
575    ["nau" ] = "nauruan",
576    ["nav" ] = "navajo",
577    ["ncr" ] = "n-cree",
578    ["ndb" ] = "ndebele",
579    ["ndc" ] = "ndau",
580    ["ndg" ] = "ndonga",
581    ["nds" ] = "low saxon",
582    ["nep" ] = "nepali",
583    ["new" ] = "newari",
584    ["nga" ] = "ngbaka",
585    ["ngr" ] = "nagari",
586    ["nhc" ] = "norway house cree",
587    ["nis" ] = "nisi",
588    ["niu" ] = "niuean",
589    ["nkl" ] = "nyankole",
590    ["nko" ] = "n'ko",
591    ["nld" ] = "dutch",
592    ["noe" ] = "nimadi",
593    ["nog" ] = "nogai",
594    ["nor" ] = "norwegian",
595    ["nov" ] = "novial",
596    ["nsm" ] = "northern sami",
597    ["nso" ] = "sotho, northern",
598    ["nta" ] = "northern tai",
599    ["nto" ] = "esperanto",
600    ["nym" ] = "nyamwezi",
601    ["nyn" ] = "norwegian nynorsk",
602    ["nza" ] = "mbembe tigon",
603    ["oci" ] = "occitan",
604    ["ocr" ] = "oji-cree",
605    ["ojb" ] = "ojibway",
606    ["ori" ] = "odia",
607    ["oro" ] = "oromo",
608    ["oss" ] = "ossetian",
609    ["paa" ] = "palestinian aramaic",
610    ["pag" ] = "pangasinan",
611    ["pal" ] = "pali",
612    ["pam" ] = "pampangan",
613    ["pan" ] = "punjabi",
614    ["pap" ] = "palpa",
615    ["pap0"] = "papiamentu",
616    ["pas" ] = "pashto",
617    ["pau" ] = "palauan",
618    ["pcc" ] = "bouyei",
619    ["pcd" ] = "picard",
620    ["pdc" ] = "pennsylvania german",
621    ["pgr" ] = "polytonic greek",
622    ["phk" ] = "phake",
623    ["pih" ] = "norfolk",
624    ["pil" ] = "filipino",
625    ["plg" ] = "palaung",
626    ["plk" ] = "polish",
627    ["pms" ] = "piemontese",
628    ["pnb" ] = "western panjabi",
629    ["poh" ] = "pocomchi",
630    ["pon" ] = "pohnpeian",
631    ["pro" ] = "provencal",
632    ["ptg" ] = "portuguese",
633    ["pwo" ] = "western pwo karen",
634    ["qin" ] = "chin",
635    ["quc" ] = "k’iche’",
636    ["quh" ] = "quechua (bolivia)",
637    ["quz" ] = "quechua",
638    ["qvi" ] = "quechua (ecuador)",
639    ["qwh" ] = "quechua (peru)",
640    ["raj" ] = "rajasthani",
641    ["rar" ] = "rarotongan",
642    ["rbu" ] = "russian buriat",
643    ["rcr" ] = "r-cree",
644    ["rej" ] = "rejang",
645    ["ria" ] = "riang",
646    ["rif" ] = "tarifit",
647    ["rit" ] = "ritarungo",
648    ["rkw" ] = "arakwal",
649    ["rms" ] = "romansh",
650    ["rmy" ] = "vlax romani",
651    ["rom" ] = "romanian",
652    ["roy" ] = "romany",
653    ["rsy" ] = "rusyn",
654    ["rtm" ] = "rotuman",
655    ["rua" ] = "kinyarwanda",
656    ["run" ] = "rundi",
657    ["rup" ] = "aromanian",
658    ["rus" ] = "russian",
659    ["sad" ] = "sadri",
660    ["san" ] = "sanskrit",
661    ["sas" ] = "sasak",
662    ["sat" ] = "santali",
663    ["say" ] = "sayisi",
664    ["scn" ] = "sicilian",
665    ["sco" ] = "scots",
666    ["scs" ] = "north slavey",
667    ["sek" ] = "sekota",
668    ["sel" ] = "selkup",
669    ["sga" ] = "old irish",
670    ["sgo" ] = "sango",
671    ["sgs" ] = "samogitian",
672    ["shi" ] = "tachelhit",
673    ["shn" ] = "shan",
674    ["sib" ] = "sibe",
675    ["sid" ] = "sidamo",
676    ["sig" ] = "silte gurage",
677    ["sks" ] = "skolt sami",
678    ["sky" ] = "slovak",
679    ["sla" ] = "slavey",
680    ["slv" ] = "slovenian",
681    ["sml" ] = "somali",
682    ["smo" ] = "samoan",
683    ["sna" ] = "sena",
684    ["sna0"] = "shona",
685    ["snd" ] = "sindhi",
686    ["snh" ] = "sinhala (sinhalese)",
687    ["snk" ] = "soninke",
688    ["sog" ] = "sodo gurage",
689    ["sop" ] = "songe",
690    ["sot" ] = "sotho, southern",
691    ["sqi" ] = "albanian",
692    ["srb" ] = "serbian",
693    ["srd" ] = "sardinian",
694    ["srk" ] = "saraiki",
695    ["srr" ] = "serer",
696    ["ssl" ] = "south slavey",
697    ["ssm" ] = "southern sami",
698    ["stq" ] = "saterland frisian",
699    ["suk" ] = "sukuma",
700    ["sun" ] = "sundanese",
701    ["sur" ] = "suri",
702    ["sva" ] = "svan",
703    ["sve" ] = "swedish",
704    ["swa" ] = "swadaya aramaic",
705    ["swk" ] = "swahili",
706    ["swz" ] = "swati",
707    ["sxt" ] = "sutu",
708    ["sxu" ] = "upper saxon",
709    ["syl" ] = "sylheti",
710    ["syr" ] = "syriac",
711    ["syre"] = "estrangela syriac",
712    ["syrj"] = "western syriac",
713    ["syrn"] = "eastern syriac",
714    ["szl" ] = "silesian",
715    ["tab" ] = "tabasaran",
716    ["taj" ] = "tajiki",
717    ["tam" ] = "tamil",
718    ["tat" ] = "tatar",
719    ["tcr" ] = "th-cree",
720    ["tdd" ] = "dehong dai",
721    ["tel" ] = "telugu",
722    ["tet" ] = "tetum",
723    ["tgl" ] = "tagalog",
724    ["tgn" ] = "tongan",
725    ["tgr" ] = "tigre",
726    ["tgy" ] = "tigrinya",
727    ["tha" ] = "thai",
728    ["tht" ] = "tahitian",
729    ["tib" ] = "tibetan",
730    ["tiv" ] = "tiv",
731    ["tkm" ] = "turkmen",
732    ["tmh" ] = "tamashek",
733    ["tmn" ] = "temne",
734    ["tna" ] = "tswana",
735    ["tne" ] = "tundra nenets",
736    ["tng" ] = "tonga",
737    ["tod" ] = "todo",
738    ["tod0"] = "toma",
739    ["tpi" ] = "tok pisin",
740    ["trk" ] = "turkish",
741    ["tsg" ] = "tsonga",
742    ["tsj" ] = "tshangla",
743    ["tua" ] = "turoyo aramaic",
744    ["tul" ] = "tulu",
745    ["tum" ] = "tulu",
746    ["tuv" ] = "tuvin",
747    ["tvl" ] = "tuvalu",
748    ["twi" ] = "twi",
749    ["tyz" ] = "tày",
750    ["tzm" ] = "tamazight",
751    ["tzo" ] = "tzotzil",
752    ["udm" ] = "udmurt",
753    ["ukr" ] = "ukrainian",
754    ["umb" ] = "umbundu",
755    ["urd" ] = "urdu",
756    ["usb" ] = "upper sorbian",
757    ["uyg" ] = "uyghur",
758    ["uzb" ] = "uzbek",
759    ["vec" ] = "venetian",
760    ["ven" ] = "venda",
761    ["vit" ] = "vietnamese",
762    ["vol" ] = "volapük",
763    ["vro" ] = "võro",
764    ["wa"  ] = "wa",
765    ["wag" ] = "wagdi",
766    ["war" ] = "waray-waray",
767    ["wcr" ] = "west-cree",
768    ["wel" ] = "welsh",
769    ["wlf" ] = "wolof",
770    ["wln" ] = "walloon",
771    ["wtm" ] = "mewati",
772    ["xbd" ] = "",
773    ["xhs" ] = "xhosa",
774    ["xjb" ] = "minjangbal",
775    ["xkf" ] = "khengkha",
776    ["xog" ] = "soga",
777    ["xpe" ] = "kpelle (liberia)",
778    ["yak" ] = "sakha",
779    ["yao" ] = "yao",
780    ["yap" ] = "yapese",
781    ["yba" ] = "yoruba",
782    ["ycr" ] = "y-cree",
783    ["yic" ] = "yi classic",
784    ["yim" ] = "yi modern",
785    ["zea" ] = "zealandic",
786    ["zgh" ] = "standard morrocan tamazigh",
787    ["zha" ] = "zhuang",
788    ["zhh" ] = "chinese, hong kong sar",
789    ["zhp" ] = "chinese phonetic",
790    ["zhs" ] = "chinese simplified",
791    ["zht" ] = "chinese traditional",
792    ["znd" ] = "zande",
793    ["zul" ] = "zulu",
794    ["zza" ] = "zazaki",
795}
796
797
798local features = allocate {
799    ["aalt"] = "access all alternates",
800    ["abvf"] = "above-base forms",
801    ["abvm"] = "above-base mark positioning",
802    ["abvs"] = "above-base substitutions",
803    ["afrc"] = "alternative fractions",
804    ["akhn"] = "akhands",
805    ["blwf"] = "below-base forms",
806    ["blwm"] = "below-base mark positioning",
807    ["blws"] = "below-base substitutions",
808    ["c2pc"] = "petite capitals from capitals",
809    ["c2sc"] = "small capitals from capitals",
810    ["calt"] = "contextual alternates",
811    ["case"] = "case-sensitive forms",
812    ["ccmp"] = "glyph composition/decomposition",
813    ["cfar"] = "conjunct form after ro",
814    ["cjct"] = "conjunct forms",
815    ["clig"] = "contextual ligatures",
816    ["cpct"] = "centered cjk punctuation",
817    ["cpsp"] = "capital spacing",
818    ["cswh"] = "contextual swash",
819    ["curs"] = "cursive positioning",
820    ["dflt"] = "default processing",
821    ["dist"] = "distances",
822    ["dlig"] = "discretionary ligatures",
823    ["dnom"] = "denominators",
824    ["dtls"] = "dotless forms",                    -- math
825    ["expt"] = "expert forms",
826    ["falt"] = "final glyph alternates",
827    ["fin2"] = "terminal forms #2",
828    ["fin3"] = "terminal forms #3",
829    ["fina"] = "terminal forms",
830    ["flac"] = "flattened accents over capitals",  -- math
831    ["frac"] = "fractions",
832    ["fwid"] = "full width",
833    ["half"] = "half forms",
834    ["haln"] = "halant forms",
835    ["halt"] = "alternate half width",
836    ["hist"] = "historical forms",
837    ["hkna"] = "horizontal kana alternates",
838    ["hlig"] = "historical ligatures",
839    ["hngl"] = "hangul",                           -- depricated
840    ["hojo"] = "hojo kanji forms",
841    ["hwid"] = "half width",
842    ["init"] = "initial forms",
843    ["isol"] = "isolated forms",
844    ["ital"] = "italics",
845    ["jalt"] = "justification alternatives",
846    ["jp04"] = "jis2004 forms",
847    ["jp78"] = "jis78 forms",
848    ["jp83"] = "jis83 forms",
849    ["jp90"] = "jis90 forms",
850    ["kern"] = "kerning",
851    ["lfbd"] = "left bounds",
852    ["liga"] = "standard ligatures",
853    ["ljmo"] = "leading jamo forms",
854    ["lnum"] = "lining figures",
855    ["locl"] = "localized forms",
856    ["ltra"] = "left-to-right alternates",
857    ["ltrm"] = "left-to-right mirrored forms",
858    ["mark"] = "mark positioning",
859    ["med2"] = "medial forms #2",
860    ["medi"] = "medial forms",
861    ["mgrk"] = "mathematical greek",
862    ["mkmk"] = "mark to mark positioning",
863    ["mset"] = "mark positioning via substitution",
864    ["nalt"] = "alternate annotation forms",
865    ["nlck"] = "nlc kanji forms",
866    ["nukt"] = "nukta forms",
867    ["numr"] = "numerators",
868    ["onum"] = "old style figures",
869    ["opbd"] = "optical bounds",
870    ["ordn"] = "ordinals",
871    ["ornm"] = "ornaments",
872    ["palt"] = "proportional alternate width",
873    ["pcap"] = "petite capitals",
874    ["pkna"] = "proportional kana",
875    ["pnum"] = "proportional figures",
876    ["pref"] = "pre-base forms",
877    ["pres"] = "pre-base substitutions",
878    ["pstf"] = "post-base forms",
879    ["psts"] = "post-base substitutions",
880    ["pwid"] = "proportional widths",
881    ["qwid"] = "quarter widths",
882    ["rand"] = "randomize",
883    ["rclt"] = "required contextual alternates",
884    ["rkrf"] = "rakar forms",
885    ["rlig"] = "required ligatures",
886    ["rphf"] = "reph form",
887    ["rtbd"] = "right bounds",
888    ["rtla"] = "right-to-left alternates",
889    ["rtlm"] = "right to left mirrored forms",
890    ["rvrn"] = "required variation alternates",
891    ["ruby"] = "ruby notation forms",
892    ["salt"] = "stylistic alternates",
893    ["sinf"] = "scientific inferiors",
894    ["size"] = "optical size", -- now stat table
895    ["smcp"] = "small capitals",
896    ["smpl"] = "simplified forms",
897 -- ["ss01"] = "stylistic set 1",
898 -- ["ss02"] = "stylistic set 2",
899 -- ["ss03"] = "stylistic set 3",
900 -- ["ss04"] = "stylistic set 4",
901 -- ["ss05"] = "stylistic set 5",
902 -- ["ss06"] = "stylistic set 6",
903 -- ["ss07"] = "stylistic set 7",
904 -- ["ss08"] = "stylistic set 8",
905 -- ["ss09"] = "stylistic set 9",
906 -- ["ss10"] = "stylistic set 10",
907 -- ["ss11"] = "stylistic set 11",
908 -- ["ss12"] = "stylistic set 12",
909 -- ["ss13"] = "stylistic set 13",
910 -- ["ss14"] = "stylistic set 14",
911 -- ["ss15"] = "stylistic set 15",
912 -- ["ss16"] = "stylistic set 16",
913 -- ["ss17"] = "stylistic set 17",
914 -- ["ss18"] = "stylistic set 18",
915 -- ["ss19"] = "stylistic set 19",
916 -- ["ss20"] = "stylistic set 20",
917    ["ssty"] = "script style", -- math
918    ["stch"] = "stretching glyph decomposition",
919    ["subs"] = "subscript",
920    ["sups"] = "superscript",
921    ["swsh"] = "swash",
922    ["titl"] = "titling",
923    ["tjmo"] = "trailing jamo forms",
924    ["tnam"] = "traditional name forms",
925    ["tnum"] = "tabular figures",
926    ["trad"] = "traditional forms",
927    ["twid"] = "third widths",
928    ["unic"] = "unicase",
929    ["valt"] = "alternate vertical metrics",
930    ["vatu"] = "vattu variants",
931    ["vert"] = "vertical writing",
932    ["vhal"] = "alternate vertical half metrics",
933    ["vjmo"] = "vowel jamo forms",
934    ["vkna"] = "vertical kana alternates",
935    ["vkrn"] = "vertical kerning",
936    ["vpal"] = "proportional alternate vertical metrics",
937    ["vrtr"] = "vertical alternates for rotation",
938    ["vrt2"] = "vertical rotation",
939    ["zero"] = "slashed zero",
940
941    ["trep"] = "traditional tex replacements",
942    ["tlig"] = "traditional tex ligatures",
943
944    ["ss.."] = "stylistic set ..",
945    ["cv.."] = "character variant ..",
946    ["js.."] = "justification ..",
947
948    ["dv.."] = "devanagari ..", -- for internal use
949    ["ml.."] = "malayalam ..",  -- for internal use
950
951}
952
953local baselines = allocate {
954    ["hang"] = "hanging baseline",
955    ["icfb"] = "ideographic character face bottom edge baseline",
956    ["icft"] = "ideographic character face tope edige baseline",
957    ["ideo"] = "ideographic em-box bottom edge baseline",
958    ["idtp"] = "ideographic em-box top edge baseline",
959    ["math"] = "mathematical centered baseline",
960    ["romn"] = "roman baseline"
961}
962
963tables.scripts   = scripts
964tables.languages = languages
965tables.features  = features
966tables.baselines = baselines
967
968local acceptscripts   = true  directives.register("otf.acceptscripts",   function(v) acceptscripts   = v end)
969local acceptlanguages = true  directives.register("otf.acceptlanguages", function(v) acceptlanguages = v end)
970
971local report_checks   = logs.reporter("fonts","checks")
972
973-- hm, we overload the metatables
974
975if otffeatures.features then
976    for k, v in next, otffeatures.features do
977        features[k] = v
978    end
979    otffeatures.features = features
980end
981
982local function swapped(h)
983    local r = { }
984    for k, v in next, h do
985        r[gsub(v,"[^a-z0-9]","")] = k -- is already lower
986    end
987    return r
988end
989
990local verbosescripts   = allocate(swapped(scripts  ))
991local verboselanguages = allocate(swapped(languages))
992local verbosefeatures  = allocate(swapped(features ))
993local verbosebaselines = allocate(swapped(baselines))
994
995-- lets forget about trailing spaces
996
997local function resolve(t,k)
998    if k then
999        k = gsub(lower(k),"[^a-z0-9]","")
1000        local v = rawget(t,k)
1001        if v then
1002            return v
1003        end
1004    end
1005end
1006
1007setmetatableindex(verbosescripts,   resolve)
1008setmetatableindex(verboselanguages, resolve)
1009setmetatableindex(verbosefeatures,  resolve)
1010setmetatableindex(verbosebaselines, resolve)
1011
1012-- We could optimize the next lookups by using an extra metatable and storing
1013-- already found values but in practice there are not that many lookups so
1014-- it's never a bottleneck.
1015
1016setmetatableindex(scripts, function(t,k)
1017    if k then
1018        k = lower(k)
1019        if k == "dflt" then
1020            return k
1021        end
1022        local v = rawget(t,k)
1023        if v then
1024            return v
1025        end
1026        k = gsub(k," ","")
1027        v = rawget(t,v)
1028        if v then
1029            return v
1030        elseif acceptscripts then
1031            report_checks("registering extra script %a",k)
1032            rawset(t,k,k)
1033            return k
1034        end
1035    end
1036    return "dflt"
1037end)
1038
1039setmetatableindex(languages, function(t,k)
1040    if k then
1041        k = lower(k)
1042        if k == "dflt" then
1043            return k
1044        end
1045        local v = rawget(t,k)
1046        if v then
1047            return v
1048        end
1049        k = gsub(k," ","")
1050        v = rawget(t,v)
1051        if v then
1052            return v
1053        elseif acceptlanguages then
1054            report_checks("registering extra language %a",k)
1055            rawset(t,k,k)
1056            return k
1057        end
1058    end
1059    return "dflt"
1060end)
1061
1062if setmetatablenewindex then
1063
1064    setmetatablenewindex(languages, "ignore")
1065    setmetatablenewindex(scripts,   "ignore")
1066    setmetatablenewindex(baselines, "ignore")
1067
1068end
1069
1070local function resolve(t,k)
1071    if k then
1072        k = lower(k)
1073        local v = rawget(t,k)
1074        if v then
1075            return v
1076        end
1077        k = gsub(k," ","")
1078        local v = rawget(t,k)
1079        if v then
1080            return v
1081        end
1082        local tag, dd = match(k,"(..)(%d+)")
1083        if tag and dd then
1084            local v = rawget(t,tag)
1085            if v then
1086                return v -- return format(v,tonumber(dd)) -- old way
1087            else
1088                local v = rawget(t,tag.."..") -- nicer in overview
1089                if v then
1090                    return (gsub(v,"%.%.",tonumber(dd))) -- new way
1091                end
1092            end
1093        end
1094    end
1095    return k -- "dflt"
1096end
1097
1098setmetatableindex(features, resolve)
1099
1100local function assign(t,k,v)
1101    if k and v then
1102        v = lower(v)
1103        rawset(t,k,v) -- rawset ?
1104     -- rawset(features,gsub(v,"[^a-z0-9]",""),k) -- why ? old code
1105    end
1106end
1107
1108if setmetatablenewindex then
1109
1110    setmetatablenewindex(features, assign)
1111
1112end
1113
1114local checkers = {
1115    rand = function(v)
1116        return v == true and "random" or v
1117    end
1118}
1119
1120if not storage then
1121    return
1122end
1123
1124local usedfeatures      = statistics.usedfeatures or { }
1125statistics.usedfeatures = usedfeatures
1126
1127table.setmetatableindex(usedfeatures, function(t,k) if k then local v = { } t[k] = v return v end end) -- table.autotable
1128
1129storage.register("fonts/otf/usedfeatures", usedfeatures, "fonts.handlers.otf.statistics.usedfeatures" )
1130
1131local normalizedaxis = otf.readers.helpers.normalizedaxis or function(s) return s end
1132
1133function otffeatures.normalize(features,wrap) -- wrap is for context
1134    if features then
1135        local h = { }
1136        for key, value in next, features do
1137            local k = lower(key)
1138            if k == "language" then
1139                local v = gsub(lower(value),"[^a-z0-9]","")
1140                h.language = rawget(verboselanguages,v) or (languages[v] and v) or "dflt" -- auto adds
1141            elseif k == "script" then
1142                local v = gsub(lower(value),"[^a-z0-9]","")
1143                h.script = rawget(verbosescripts,v) or (scripts[v] and v) or "dflt" -- auto adds
1144            elseif k == "axis" then
1145                h[k] = normalizedaxis(value)
1146            else
1147                local uk = usedfeatures[key]
1148                local uv = uk[value]
1149                if uv then
1150                 -- report_checks("feature value %a first seen at %a",value,key)
1151                else
1152                    uv = tonumber(value) -- before boolean as there we also handle 0/1
1153                    if uv then
1154                        -- we're okay
1155                    elseif type(value) == "string" then
1156                        local b = is_boolean(value)
1157                        if type(b) == "nil" then
1158                         -- we do this elsewhere
1159                         --
1160                         -- if find(value,"=") then
1161                         --     local t = { }
1162                         --     for k, v in gmatch(value,"([^%s,=]+)%s*=%s*([^%s,=]+)") do
1163                         --         t[k] = tonumber(v) or v
1164                         --     end
1165                         --     if next(t) then
1166                         --         value = sequenced(t,",")
1167                         --     end
1168                         -- end
1169                            if wrap and find(value,",") then
1170                                uv = "{"..lower(value).."}"
1171                            else
1172                                uv = lower(value)
1173                            end
1174                        else
1175                            uv = b
1176                        end
1177                    elseif type(value) == "table" then
1178                        uv = sequenced(t,",")
1179                    else
1180                        uv = value
1181                    end
1182                    if not rawget(features,k) then
1183                        k = rawget(verbosefeatures,k) or k
1184                    end
1185                    local c = checkers[k]
1186                    if c then
1187                        uv = c(uv) or vc
1188                    end
1189                    uk[value] = uv
1190                end
1191                h[k] = uv
1192            end
1193        end
1194        return h
1195    end
1196end
1197