1/*
2 * Copyright © 2009 Red Hat, Inc.
3 * Copyright © 2011 Google, Inc.
4 *
5 * This is part of HarfBuzz, a text shaping library.
6 *
7 * Permission is hereby granted, without written agreement and without
8 * license or royalty fees, to use, copy, modify, and distribute this
9 * software and its documentation for any purpose, provided that the
10 * above copyright notice and the following two paragraphs appear in
11 * all copies of this software.
12 *
13 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
14 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
15 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
16 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
17 * DAMAGE.
18 *
19 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
20 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
22 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
23 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
24 *
25 * Red Hat Author(s): Behdad Esfahbod
26 * Google Author(s): Behdad Esfahbod, Roozbeh Pournader
27 */
28
29#include "hb.hh"
30
31
32/* hb_script_t */
33
34static hb_tag_t
35hb_ot_old_tag_from_script (hb_script_t script)
36{
37 /* This seems to be accurate as of end of 2012. */
38
39 switch ((hb_tag_t) script) {
40 case HB_SCRIPT_INVALID: return HB_OT_TAG_DEFAULT_SCRIPT;
41
42 /* KATAKANA and HIRAGANA both map to 'kana' */
43 case HB_SCRIPT_HIRAGANA: return HB_TAG('k','a','n','a');
44
45 /* Spaces at the end are preserved, unlike ISO 15924 */
46 case HB_SCRIPT_LAO: return HB_TAG('l','a','o',' ');
47 case HB_SCRIPT_YI: return HB_TAG('y','i',' ',' ');
48 /* Unicode-5.0 additions */
49 case HB_SCRIPT_NKO: return HB_TAG('n','k','o',' ');
50 /* Unicode-5.1 additions */
51 case HB_SCRIPT_VAI: return HB_TAG('v','a','i',' ');
52 /* Unicode-5.2 additions */
53 /* Unicode-6.0 additions */
54 }
55
56 /* Else, just change first char to lowercase and return */
57 return ((hb_tag_t) script) | 0x20000000u;
58}
59
60static hb_script_t
61hb_ot_old_tag_to_script (hb_tag_t tag)
62{
63 if (unlikely (tag == HB_OT_TAG_DEFAULT_SCRIPT))
64 return HB_SCRIPT_INVALID;
65
66 /* This side of the conversion is fully algorithmic. */
67
68 /* Any spaces at the end of the tag are replaced by repeating the last
69 * letter. Eg 'nko ' -> 'Nkoo' */
70 if (unlikely ((tag & 0x0000FF00u) == 0x00002000u))
71 tag |= (tag >> 8) & 0x0000FF00u; /* Copy second letter to third */
72 if (unlikely ((tag & 0x000000FFu) == 0x00000020u))
73 tag |= (tag >> 8) & 0x000000FFu; /* Copy third letter to fourth */
74
75 /* Change first char to uppercase and return */
76 return (hb_script_t) (tag & ~0x20000000u);
77}
78
79static hb_tag_t
80hb_ot_new_tag_from_script (hb_script_t script)
81{
82 switch ((hb_tag_t) script) {
83 case HB_SCRIPT_BENGALI: return HB_TAG('b','n','g','2');
84 case HB_SCRIPT_DEVANAGARI: return HB_TAG('d','e','v','2');
85 case HB_SCRIPT_GUJARATI: return HB_TAG('g','j','r','2');
86 case HB_SCRIPT_GURMUKHI: return HB_TAG('g','u','r','2');
87 case HB_SCRIPT_KANNADA: return HB_TAG('k','n','d','2');
88 case HB_SCRIPT_MALAYALAM: return HB_TAG('m','l','m','2');
89 case HB_SCRIPT_ORIYA: return HB_TAG('o','r','y','2');
90 case HB_SCRIPT_TAMIL: return HB_TAG('t','m','l','2');
91 case HB_SCRIPT_TELUGU: return HB_TAG('t','e','l','2');
92 case HB_SCRIPT_MYANMAR: return HB_TAG('m','y','m','2');
93 }
94
95 return HB_OT_TAG_DEFAULT_SCRIPT;
96}
97
98static hb_script_t
99hb_ot_new_tag_to_script (hb_tag_t tag)
100{
101 switch (tag) {
102 case HB_TAG('b','n','g','2'): return HB_SCRIPT_BENGALI;
103 case HB_TAG('d','e','v','2'): return HB_SCRIPT_DEVANAGARI;
104 case HB_TAG('g','j','r','2'): return HB_SCRIPT_GUJARATI;
105 case HB_TAG('g','u','r','2'): return HB_SCRIPT_GURMUKHI;
106 case HB_TAG('k','n','d','2'): return HB_SCRIPT_KANNADA;
107 case HB_TAG('m','l','m','2'): return HB_SCRIPT_MALAYALAM;
108 case HB_TAG('o','r','y','2'): return HB_SCRIPT_ORIYA;
109 case HB_TAG('t','m','l','2'): return HB_SCRIPT_TAMIL;
110 case HB_TAG('t','e','l','2'): return HB_SCRIPT_TELUGU;
111 case HB_TAG('m','y','m','2'): return HB_SCRIPT_MYANMAR;
112 }
113
114 return HB_SCRIPT_UNKNOWN;
115}
116
117/*
118 * Complete list at:
119 * https://docs.microsoft.com/en-us/typography/opentype/spec/scripttags
120 *
121 * Most of the script tags are the same as the ISO 15924 tag but lowercased.
122 * So we just do that, and handle the exceptional cases in a switch.
123 */
124
125void
126hb_ot_tags_from_script (hb_script_t script,
127 hb_tag_t *script_tag_1,
128 hb_tag_t *script_tag_2)
129{
130 hb_tag_t new_tag;
131
132 *script_tag_2 = HB_OT_TAG_DEFAULT_SCRIPT;
133 *script_tag_1 = hb_ot_old_tag_from_script (script);
134
135 new_tag = hb_ot_new_tag_from_script (script);
136 if (unlikely (new_tag != HB_OT_TAG_DEFAULT_SCRIPT)) {
137 *script_tag_2 = *script_tag_1;
138 *script_tag_1 = new_tag;
139 }
140}
141
142hb_script_t
143hb_ot_tag_to_script (hb_tag_t tag)
144{
145 if (unlikely ((tag & 0x000000FFu) == '2'))
146 return hb_ot_new_tag_to_script (tag);
147
148 return hb_ot_old_tag_to_script (tag);
149}
150
151
152/* hb_language_t */
153
154typedef struct {
155 char language[4];
156 hb_tag_t tag;
157} LangTag;
158
159/*
160 * Complete list at:
161 * https://docs.microsoft.com/en-us/typography/opentype/spec/languagetags
162 *
163 * Generated by intersecting the OpenType language tag list from
164 * Draft OpenType 1.5 spec, with with the ISO 639-3 codes from
165 * 2008-08-04, matching on name, and finally adjusted manually.
166 *
167 * Updated on 2012-12-07 with more research into remaining codes.
168 *
169 * Updated on 2013-11-23 based on usage in SIL and Microsoft fonts,
170 * the new proposal from Microsoft, and latest ISO 639-3 names.
171 *
172 * Some items still missing. Those are commented out at the end.
173 * Keep sorted for bsearch.
174 *
175 * Updated as of 2015-05-06: OT1.7 on MS website has some newer
176 * items that we don't have here, eg. Zazaki. This is the new
177 * items in OpenType 1.7 (red items), most of which we have:
178 * https://docs.microsoft.com/en-us/typography/opentype/spec/languagetags
179 */
180
181static const LangTag ot_languages[] = {
182 {"aa", HB_TAG('A','F','R',' ')}, /* Afar */
183 {"ab", HB_TAG('A','B','K',' ')}, /* Abkhazian */
184 {"abq", HB_TAG('A','B','A',' ')}, /* Abaza */
185 {"acf", HB_TAG('F','A','N',' ')}, /* French Antillean */
186 {"ach", HB_TAG('A','C','H',' ')}, /* Acoli */
187 {"acr", HB_TAG('A','C','R',' ')}, /* Achi */
188 {"ada", HB_TAG('D','N','G',' ')}, /* Dangme */
189 {"ady", HB_TAG('A','D','Y',' ')}, /* Adyghe */
190 {"af", HB_TAG('A','F','K',' ')}, /* Afrikaans */
191 {"ahg", HB_TAG('A','G','W',' ')}, /* Agaw */
192 {"aii", HB_TAG('S','W','A',' ')}, /* Swadaya Aramaic */
193 {"aio", HB_TAG('A','I','O',' ')}, /* Aiton */
194 {"aiw", HB_TAG('A','R','I',' ')}, /* Aari */
195 {"ak", HB_TAG('T','W','I',' ')}, /* Akan [macrolanguage] */
196 {"aka", HB_TAG('A','K','A',' ')}, /* Akan */
197 {"alt", HB_TAG('A','L','T',' ')}, /* [Southern] Altai */
198 {"am", HB_TAG('A','M','H',' ')}, /* Amharic */
199 {"amf", HB_TAG('H','B','N',' ')}, /* Hammer-Banna */
200 {"amw", HB_TAG('S','Y','R',' ')}, /* Western Neo-Aramaic */
201 {"an", HB_TAG('A','R','G',' ')}, /* Aragonese */
202 {"ang", HB_TAG('A','N','G',' ')}, /* Old English (ca. 450-1100) */
203 {"ar", HB_TAG('A','R','A',' ')}, /* Arabic [macrolanguage] */
204 {"arb", HB_TAG('A','R','A',' ')}, /* Standard Arabic */
205 {"arn", HB_TAG('M','A','P',' ')}, /* Mapudungun */
206 {"ary", HB_TAG('M','O','R',' ')}, /* Moroccan Arabic */
207 {"as", HB_TAG('A','S','M',' ')}, /* Assamese */
208 {"ast", HB_TAG('A','S','T',' ')}, /* Asturian/Asturleonese/Bable/Leonese */
209 {"ath", HB_TAG('A','T','H',' ')}, /* Athapaskan [family] */
210 {"atj", HB_TAG('R','C','R',' ')}, /* R-Cree */
211 {"atv", HB_TAG('A','L','T',' ')}, /* [Northern] Altai */
212 {"av", HB_TAG('A','V','R',' ')}, /* Avaric */
213 {"awa", HB_TAG('A','W','A',' ')}, /* Awadhi */
214 {"ay", HB_TAG('A','Y','M',' ')}, /* Aymara [macrolanguage] */
215 {"az", HB_TAG('A','Z','E',' ')}, /* Azerbaijani [macrolanguage] */
216 {"azb", HB_TAG('A','Z','B',' ')}, /* South Azerbaijani */
217 {"azj", HB_TAG('A','Z','E',' ')}, /* North Azerbaijani */
218 {"ba", HB_TAG('B','S','H',' ')}, /* Bashkir */
219 {"bad", HB_TAG('B','A','D','0')}, /* Banda */
220 {"bai", HB_TAG('B','M','L',' ')}, /* Bamileke [family] */
221 {"bal", HB_TAG('B','L','I',' ')}, /* Baluchi [macrolangauge] */
222 {"ban", HB_TAG('B','A','N',' ')}, /* Balinese */
223 {"bar", HB_TAG('B','A','R',' ')}, /* Bavarian */
224 {"bbc", HB_TAG('B','B','C',' ')}, /* Batak Toba */
225 {"bci", HB_TAG('B','A','U',' ')}, /* Baoulé */
226 {"bcl", HB_TAG('B','I','K',' ')}, /* Central Bikol */
227 {"bcq", HB_TAG('B','C','H',' ')}, /* Bench */
228 {"bdy", HB_TAG('B','D','Y',' ')}, /* Bandjalang */
229 {"be", HB_TAG('B','E','L',' ')}, /* Belarusian */
230 {"bem", HB_TAG('B','E','M',' ')}, /* Bemba (Zambia) */
231 {"ber", HB_TAG('B','E','R',' ')}, /* Berber [family] */
232 {"bfq", HB_TAG('B','A','D',' ')}, /* Badaga */
233 {"bft", HB_TAG('B','L','T',' ')}, /* Balti */
234 {"bfu", HB_TAG('L','A','H',' ')}, /* Lahuli */
235 {"bfy", HB_TAG('B','A','G',' ')}, /* Baghelkhandi */
236 {"bg", HB_TAG('B','G','R',' ')}, /* Bulgarian */
237 {"bgc", HB_TAG('B','G','C',' ')}, /* Haryanvi */
238 {"bgq", HB_TAG('B','G','Q',' ')}, /* Bagri */
239 {"bgr", HB_TAG('Q','I','N',' ')}, /* Bawm Chin */
240 {"bhb", HB_TAG('B','H','I',' ')}, /* Bhili */
241 {"bhk", HB_TAG('B','I','K',' ')}, /* Albay Bicolano (retired code) */
242 {"bho", HB_TAG('B','H','O',' ')}, /* Bhojpuri */
243 {"bi", HB_TAG('B','I','S',' ')}, /* Bislama */
244 {"bik", HB_TAG('B','I','K',' ')}, /* Bikol [macrolanguage] */
245 {"bin", HB_TAG('E','D','O',' ')}, /* Bini */
246 {"bjj", HB_TAG('B','J','J',' ')}, /* Kanauji */
247 {"bjt", HB_TAG('B','L','N',' ')}, /* Balanta-Ganja */
248 {"bla", HB_TAG('B','K','F',' ')}, /* Blackfoot */
249 {"ble", HB_TAG('B','L','N',' ')}, /* Balanta-Kentohe */
250 {"blk", HB_TAG('B','L','K',' ')}, /* Pa'O/Pa'o Karen */
251 {"bln", HB_TAG('B','I','K',' ')}, /* Southern Catanduanes Bikol */
252 {"bm", HB_TAG('B','M','B',' ')}, /* Bambara */
253 {"bn", HB_TAG('B','E','N',' ')}, /* Bengali */
254 {"bo", HB_TAG('T','I','B',' ')}, /* Tibetan */
255 {"bpy", HB_TAG('B','P','Y',' ')}, /* Bishnupriya */
256 {"bqi", HB_TAG('L','R','C',' ')}, /* Bakhtiari */
257 {"br", HB_TAG('B','R','E',' ')}, /* Breton */
258 {"bra", HB_TAG('B','R','I',' ')}, /* Braj Bhasha */
259 {"brh", HB_TAG('B','R','H',' ')}, /* Brahui */
260 {"brx", HB_TAG('B','R','X',' ')}, /* Bodo (India) */
261 {"bs", HB_TAG('B','O','S',' ')}, /* Bosnian */
262 {"btb", HB_TAG('B','T','I',' ')}, /* Beti (Cameroon) */
263 {"bto", HB_TAG('B','I','K',' ')}, /* Rinconada Bikol */
264 {"bts", HB_TAG('B','T','S',' ')}, /* Batak Simalungun */
265 {"bug", HB_TAG('B','U','G',' ')}, /* Buginese */
266 {"bxr", HB_TAG('R','B','U',' ')}, /* Russian Buriat */
267 {"byn", HB_TAG('B','I','L',' ')}, /* Bilen */
268 {"ca", HB_TAG('C','A','T',' ')}, /* Catalan */
269 {"cak", HB_TAG('C','A','K',' ')}, /* Kaqchikel */
270 {"cbk", HB_TAG('C','B','K',' ')}, /* Chavacano */
271 {"cbl", HB_TAG('Q','I','N',' ')}, /* Bualkhaw Chin */
272 {"cco", HB_TAG('C','C','H','N')}, /* Chinantec */
273 {"ce", HB_TAG('C','H','E',' ')}, /* Chechen */
274 {"ceb", HB_TAG('C','E','B',' ')}, /* Cebuano */
275 {"cfm", HB_TAG('H','A','L',' ')}, /* Halam/Falam Chin */
276 {"cgg", HB_TAG('C','G','G',' ')}, /* Chiga */
277 {"ch", HB_TAG('C','H','A',' ')}, /* Chamorro */
278 {"chj", HB_TAG('C','C','H','N')}, /* Chinantec */
279 {"chk", HB_TAG('C','H','K','0')}, /* Chuukese */
280 {"cho", HB_TAG('C','H','O',' ')}, /* Choctaw */
281 {"chp", HB_TAG('C','H','P',' ')}, /* Chipewyan */
282 {"chq", HB_TAG('C','C','H','N')}, /* Chinantec */
283 {"chr", HB_TAG('C','H','R',' ')}, /* Cherokee */
284 {"chy", HB_TAG('C','H','Y',' ')}, /* Cheyenne */
285 {"chz", HB_TAG('C','C','H','N')}, /* Chinantec */
286 {"cja", HB_TAG('C','J','A',' ')}, /* Western Cham */
287 {"cjm", HB_TAG('C','J','M',' ')}, /* Eastern Cham */
288 {"cka", HB_TAG('Q','I','N',' ')}, /* Khumi Awa Chin */
289 {"ckb", HB_TAG('K','U','R',' ')}, /* Central Kurdish (Sorani) */
290 {"ckt", HB_TAG('C','H','K',' ')}, /* Chukchi */
291 {"cld", HB_TAG('S','Y','R',' ')}, /* Chaldean Neo-Aramaic */
292 {"cle", HB_TAG('C','C','H','N')}, /* Chinantec */
293 {"cmr", HB_TAG('Q','I','N',' ')}, /* Mro-Khimi Chin */
294 {"cnb", HB_TAG('Q','I','N',' ')}, /* Chinbon Chin */
295 {"cnh", HB_TAG('Q','I','N',' ')}, /* Hakha Chin */
296 {"cnk", HB_TAG('Q','I','N',' ')}, /* Khumi Chin */
297 {"cnl", HB_TAG('C','C','H','N')}, /* Chinantec */
298 {"cnt", HB_TAG('C','C','H','N')}, /* Chinantec */
299 {"cnw", HB_TAG('Q','I','N',' ')}, /* Ngawn Chin */
300 {"cop", HB_TAG('C','O','P',' ')}, /* Coptic */
301 {"cpa", HB_TAG('C','C','H','N')}, /* Chinantec */
302 {"cpp", HB_TAG('C','P','P',' ')}, /* Creoles */
303 {"cr", HB_TAG('C','R','E',' ')}, /* Cree */
304 {"cre", HB_TAG('Y','C','R',' ')}, /* Y-Cree */
305 {"crh", HB_TAG('C','R','T',' ')}, /* Crimean Tatar */
306 {"crj", HB_TAG('E','C','R',' ')}, /* [Southern] East Cree */
307 {"crk", HB_TAG('W','C','R',' ')}, /* West-Cree */
308 {"crl", HB_TAG('E','C','R',' ')}, /* [Northern] East Cree */
309 {"crm", HB_TAG('M','C','R',' ')}, /* Moose Cree */
310 {"crx", HB_TAG('C','R','R',' ')}, /* Carrier */
311 {"cs", HB_TAG('C','S','Y',' ')}, /* Czech */
312 {"csa", HB_TAG('C','C','H','N')}, /* Chinantec */
313 {"csb", HB_TAG('C','S','B',' ')}, /* Kashubian */
314 {"csh", HB_TAG('Q','I','N',' ')}, /* Asho Chin */
315 {"cso", HB_TAG('C','C','H','N')}, /* Chinantec */
316 {"csy", HB_TAG('Q','I','N',' ')}, /* Siyin Chin */
317 {"ctd", HB_TAG('Q','I','N',' ')}, /* Tedim Chin */
318 {"cte", HB_TAG('C','C','H','N')}, /* Chinantec */
319 {"ctg", HB_TAG('C','T','G',' ')}, /* Chittagonian */
320 {"ctl", HB_TAG('C','C','H','N')}, /* Chinantec */
321 {"cts", HB_TAG('B','I','K',' ')}, /* Northern Catanduanes Bikol */
322 {"cu", HB_TAG('C','S','L',' ')}, /* Church Slavic */
323 {"cuc", HB_TAG('C','C','H','N')}, /* Chinantec */
324 {"cuk", HB_TAG('C','U','K',' ')}, /* San Blas Kuna */
325 {"cv", HB_TAG('C','H','U',' ')}, /* Chuvash */
326 {"cvn", HB_TAG('C','C','H','N')}, /* Chinantec */
327 {"cwd", HB_TAG('D','C','R',' ')}, /* Woods Cree */
328 {"cy", HB_TAG('W','E','L',' ')}, /* Welsh */
329 {"czt", HB_TAG('Q','I','N',' ')}, /* Zotung Chin */
330 {"da", HB_TAG('D','A','N',' ')}, /* Danish */
331 {"dao", HB_TAG('Q','I','N',' ')}, /* Daai Chin */
332 {"dap", HB_TAG('N','I','S',' ')}, /* Nisi (India) */
333 {"dar", HB_TAG('D','A','R',' ')}, /* Dargwa */
334 {"dax", HB_TAG('D','A','X',' ')}, /* Dayi */
335 {"de", HB_TAG('D','E','U',' ')}, /* German */
336 {"dgo", HB_TAG('D','G','O',' ')}, /* Dogri */
337 {"dhd", HB_TAG('M','A','W',' ')}, /* Dhundari */
338 {"dhg", HB_TAG('D','H','G',' ')}, /* Dhangu */
339 {"din", HB_TAG('D','N','K',' ')}, /* Dinka [macrolanguage] */
340 {"diq", HB_TAG('D','I','Q',' ')}, /* Dimli */
341 {"dje", HB_TAG('D','J','R',' ')}, /* Zarma */
342 {"djr", HB_TAG('D','J','R','0')}, /* Djambarrpuyngu */
343 {"dng", HB_TAG('D','U','N',' ')}, /* Dungan */
344 {"dnj", HB_TAG('D','N','J',' ')}, /* Dan */
345 {"doi", HB_TAG('D','G','R',' ')}, /* Dogri [macrolanguage] */
346 {"dsb", HB_TAG('L','S','B',' ')}, /* Lower Sorbian */
347 {"duj", HB_TAG('D','U','J',' ')}, /* Dhuwal */
348 {"dv", HB_TAG('D','I','V',' ')}, /* Dhivehi/Divehi/Maldivian */
349 {"dyu", HB_TAG('J','U','L',' ')}, /* Jula */
350 {"dz", HB_TAG('D','Z','N',' ')}, /* Dzongkha */
351 {"ee", HB_TAG('E','W','E',' ')}, /* Ewe */
352 {"efi", HB_TAG('E','F','I',' ')}, /* Efik */
353 {"ekk", HB_TAG('E','T','I',' ')}, /* Standard Estonian */
354 {"el", HB_TAG('E','L','L',' ')}, /* Modern Greek (1453-) */
355 {"emk", HB_TAG('M','N','K',' ')}, /* Eastern Maninkakan */
356 {"en", HB_TAG('E','N','G',' ')}, /* English */
357 {"enf", HB_TAG('F','N','E',' ')}, /* Forest Nenets */
358 {"enh", HB_TAG('T','N','E',' ')}, /* Tundra Nenets */
359 {"eo", HB_TAG('N','T','O',' ')}, /* Esperanto */
360 {"eot", HB_TAG('B','T','I',' ')}, /* Beti (Côte d'Ivoire) */
361 {"es", HB_TAG('E','S','P',' ')}, /* Spanish */
362 {"esu", HB_TAG('E','S','U',' ')}, /* Central Yupik */
363 {"et", HB_TAG('E','T','I',' ')}, /* Estonian [macrolanguage] */
364 {"eu", HB_TAG('E','U','Q',' ')}, /* Basque */
365 {"eve", HB_TAG('E','V','N',' ')}, /* Even */
366 {"evn", HB_TAG('E','V','K',' ')}, /* Evenki */
367 {"fa", HB_TAG('F','A','R',' ')}, /* Persian [macrolanguage] */
368 {"fan", HB_TAG('F','A','N','0')}, /* Fang */
369 {"fat", HB_TAG('F','A','T',' ')}, /* Fanti */
370 {"ff", HB_TAG('F','U','L',' ')}, /* Fulah [macrolanguage] */
371 {"fi", HB_TAG('F','I','N',' ')}, /* Finnish */
372 {"fil", HB_TAG('P','I','L',' ')}, /* Filipino */
373 {"fj", HB_TAG('F','J','I',' ')}, /* Fijian */
374 {"flm", HB_TAG('H','A','L',' ')}, /* Halam/Falam Chin [retired ISO639 code] */
375 {"fo", HB_TAG('F','O','S',' ')}, /* Faroese */
376 {"fon", HB_TAG('F','O','N',' ')}, /* Fon */
377 {"fr", HB_TAG('F','R','A',' ')}, /* French */
378 {"frc", HB_TAG('F','R','C',' ')}, /* Cajun French */
379 {"frp", HB_TAG('F','R','P',' ')}, /* Arpitan/Francoprovençal */
380 {"fuf", HB_TAG('F','T','A',' ')}, /* Futa */
381 {"fur", HB_TAG('F','R','L',' ')}, /* Friulian */
382 {"fuv", HB_TAG('F','U','V',' ')}, /* Nigerian Fulfulde */
383 {"fy", HB_TAG('F','R','I',' ')}, /* Western Frisian */
384 {"ga", HB_TAG('I','R','I',' ')}, /* Irish */
385 {"gaa", HB_TAG('G','A','D',' ')}, /* Ga */
386 {"gag", HB_TAG('G','A','G',' ')}, /* Gagauz */
387 {"gbm", HB_TAG('G','A','W',' ')}, /* Garhwali */
388 {"gd", HB_TAG('G','A','E',' ')}, /* Scottish Gaelic */
389 {"gez", HB_TAG('G','E','Z',' ')}, /* Ge'ez */
390 {"ggo", HB_TAG('G','O','N',' ')}, /* Southern Gondi */
391 {"gih", HB_TAG('G','I','H',' ')}, /* Githabul */
392 {"gil", HB_TAG('G','I','L','0')}, /* Kiribati (Gilbertese) */
393 {"gkp", HB_TAG('G','K','P',' ')}, /* Kpelle (Guinea) */
394 {"gl", HB_TAG('G','A','L',' ')}, /* Galician */
395 {"gld", HB_TAG('N','A','N',' ')}, /* Nanai */
396 {"glk", HB_TAG('G','L','K',' ')}, /* Gilaki */
397 {"gn", HB_TAG('G','U','A',' ')}, /* Guarani [macrolanguage] */
398 {"gnn", HB_TAG('G','N','N',' ')}, /* Gumatj */
399 {"gno", HB_TAG('G','O','N',' ')}, /* Northern Gondi */
400 {"gog", HB_TAG('G','O','G',' ')}, /* Gogo */
401 {"gon", HB_TAG('G','O','N',' ')}, /* Gondi [macrolanguage] */
402 {"grt", HB_TAG('G','R','O',' ')}, /* Garo */
403 {"gru", HB_TAG('S','O','G',' ')}, /* Sodo Gurage */
404 {"gsw", HB_TAG('A','L','S',' ')}, /* Alsatian */
405 {"gu", HB_TAG('G','U','J',' ')}, /* Gujarati */
406 {"guc", HB_TAG('G','U','C',' ')}, /* Wayuu */
407 {"guf", HB_TAG('G','U','F',' ')}, /* Gupapuyngu */
408 {"guk", HB_TAG('G','M','Z',' ')}, /* Gumuz */
409/*{"guk", HB_TAG('G','U','K',' ')},*/ /* Gumuz (in SIL fonts) */
410 {"guz", HB_TAG('G','U','Z',' ')}, /* Ekegusii/Gusii */
411 {"gv", HB_TAG('M','N','X',' ')}, /* Manx */
412 {"ha", HB_TAG('H','A','U',' ')}, /* Hausa */
413 {"har", HB_TAG('H','R','I',' ')}, /* Harari */
414 {"haw", HB_TAG('H','A','W',' ')}, /* Hawaiian */
415 {"hay", HB_TAG('H','A','Y',' ')}, /* Haya */
416 {"haz", HB_TAG('H','A','Z',' ')}, /* Hazaragi */
417 {"he", HB_TAG('I','W','R',' ')}, /* Hebrew */
418 {"hi", HB_TAG('H','I','N',' ')}, /* Hindi */
419 {"hil", HB_TAG('H','I','L',' ')}, /* Hiligaynon */
420 {"hlt", HB_TAG('Q','I','N',' ')}, /* Matu Chin */
421 {"hmn", HB_TAG('H','M','N',' ')}, /* Hmong */
422 {"hnd", HB_TAG('H','N','D',' ')}, /* [Southern] Hindko */
423 {"hne", HB_TAG('C','H','H',' ')}, /* Chattisgarhi */
424 {"hno", HB_TAG('H','N','D',' ')}, /* [Northern] Hindko */
425 {"ho", HB_TAG('H','M','O',' ')}, /* Hiri Motu */
426 {"hoc", HB_TAG('H','O',' ',' ')}, /* Ho */
427 {"hoj", HB_TAG('H','A','R',' ')}, /* Harauti */
428 {"hr", HB_TAG('H','R','V',' ')}, /* Croatian */
429 {"hsb", HB_TAG('U','S','B',' ')}, /* Upper Sorbian */
430 {"ht", HB_TAG('H','A','I',' ')}, /* Haitian/Haitian Creole */
431 {"hu", HB_TAG('H','U','N',' ')}, /* Hungarian */
432 {"hy", HB_TAG('H','Y','E',' ')}, /* Armenian */
433 {"hz", HB_TAG('H','E','R',' ')}, /* Herero */
434 {"ia", HB_TAG('I','N','A',' ')}, /* Interlingua (International Auxiliary Language Association) */
435 {"iba", HB_TAG('I','B','A',' ')}, /* Iban */
436 {"ibb", HB_TAG('I','B','B',' ')}, /* Ibibio */
437 {"id", HB_TAG('I','N','D',' ')}, /* Indonesian */
438 {"ie", HB_TAG('I','L','E',' ')}, /* Interlingue/Occidental */
439 {"ig", HB_TAG('I','B','O',' ')}, /* Igbo */
440 {"igb", HB_TAG('E','B','I',' ')}, /* Ebira */
441 {"ii", HB_TAG('Y','I','M',' ')}, /* Yi Modern */
442 {"ijc", HB_TAG('I','J','O',' ')}, /* Izon */
443 {"ijo", HB_TAG('I','J','O',' ')}, /* Ijo [family] */
444 {"ik", HB_TAG('I','P','K',' ')}, /* Inupiaq [macrolanguage] */
445 {"ilo", HB_TAG('I','L','O',' ')}, /* Ilokano */
446 {"inh", HB_TAG('I','N','G',' ')}, /* Ingush */
447 {"io", HB_TAG('I','D','O',' ')}, /* Ido */
448 {"is", HB_TAG('I','S','L',' ')}, /* Icelandic */
449 {"it", HB_TAG('I','T','A',' ')}, /* Italian */
450 {"iu", HB_TAG('I','N','U',' ')}, /* Inuktitut [macrolanguage] */
451 {"ja", HB_TAG('J','A','N',' ')}, /* Japanese */
452 {"jam", HB_TAG('J','A','M',' ')}, /* Jamaican Creole English */
453 {"jbo", HB_TAG('J','B','O',' ')}, /* Lojban */
454 {"jv", HB_TAG('J','A','V',' ')}, /* Javanese */
455 {"ka", HB_TAG('K','A','T',' ')}, /* Georgian */
456 {"kaa", HB_TAG('K','R','K',' ')}, /* Karakalpak */
457 {"kab", HB_TAG('K','A','B','0')}, /* Kabyle */
458 {"kam", HB_TAG('K','M','B',' ')}, /* Kamba (Kenya) */
459 {"kar", HB_TAG('K','R','N',' ')}, /* Karen [family] */
460 {"kat", HB_TAG('K','G','E',' ')}, /* Khutsuri Georgian */
461 {"kbd", HB_TAG('K','A','B',' ')}, /* Kabardian */
462 {"kde", HB_TAG('K','D','E',' ')}, /* Makonde */
463 {"kdr", HB_TAG('K','R','M',' ')}, /* Karaim */
464 {"kdt", HB_TAG('K','U','Y',' ')}, /* Kuy */
465 {"kea", HB_TAG('K','E','A',' ')}, /* Kabuverdianu (Crioulo) */
466 {"kek", HB_TAG('K','E','K',' ')}, /* Kekchi */
467 {"kex", HB_TAG('K','K','N',' ')}, /* Kokni */
468 {"kfa", HB_TAG('K','O','D',' ')}, /* Kodagu */
469 {"kfr", HB_TAG('K','A','C',' ')}, /* Kachchi */
470 {"kfx", HB_TAG('K','U','L',' ')}, /* Kulvi */
471 {"kfy", HB_TAG('K','M','N',' ')}, /* Kumaoni */
472 {"kg", HB_TAG('K','O','N',' ')}, /* Kongo [macrolanguage] */
473 {"kha", HB_TAG('K','S','I',' ')}, /* Khasi */
474 {"khb", HB_TAG('X','B','D',' ')}, /* Lü */
475 {"kht", HB_TAG('K','H','N',' ')}, /* Khamti (Microsoft fonts) */
476/*{"kht", HB_TAG('K','H','T',' ')},*/ /* Khamti (OpenType spec and SIL fonts) */
477 {"khw", HB_TAG('K','H','W',' ')}, /* Khowar */
478 {"ki", HB_TAG('K','I','K',' ')}, /* Gikuyu/Kikuyu */
479 {"kiu", HB_TAG('K','I','U',' ')}, /* Kirmanjki */
480 {"kj", HB_TAG('K','U','A',' ')}, /* Kuanyama/Kwanyama */
481 {"kjd", HB_TAG('K','J','D',' ')}, /* Southern Kiwai */
482 {"kjh", HB_TAG('K','H','A',' ')}, /* Khakass */
483 {"kjp", HB_TAG('K','J','P',' ')}, /* Pwo Eastern Karen */
484 {"kk", HB_TAG('K','A','Z',' ')}, /* Kazakh */
485 {"kl", HB_TAG('G','R','N',' ')}, /* Kalaallisut */
486 {"kln", HB_TAG('K','A','L',' ')}, /* Kalenjin */
487 {"km", HB_TAG('K','H','M',' ')}, /* Central Khmer */
488 {"kmb", HB_TAG('M','B','N',' ')}, /* Kimbundu */
489 {"kmw", HB_TAG('K','M','O',' ')}, /* Komo (Democratic Republic of Congo) */
490 {"kn", HB_TAG('K','A','N',' ')}, /* Kannada */
491 {"knn", HB_TAG('K','O','K',' ')}, /* Konkani */
492 {"ko", HB_TAG('K','O','R',' ')}, /* Korean */
493 {"koi", HB_TAG('K','O','P',' ')}, /* Komi-Permyak */
494 {"kok", HB_TAG('K','O','K',' ')}, /* Konkani [macrolanguage] */
495 {"kon", HB_TAG('K','O','N','0')}, /* Kongo */
496 {"kos", HB_TAG('K','O','S',' ')}, /* Kosraean */
497 {"kpe", HB_TAG('K','P','L',' ')}, /* Kpelle [macrolanguage] */
498 {"kpv", HB_TAG('K','O','Z',' ')}, /* Komi-Zyrian */
499 {"kpy", HB_TAG('K','Y','K',' ')}, /* Koryak */
500 {"kqy", HB_TAG('K','R','T',' ')}, /* Koorete */
501 {"kr", HB_TAG('K','N','R',' ')}, /* Kanuri [macrolanguage] */
502 {"kri", HB_TAG('K','R','I',' ')}, /* Krio */
503 {"krl", HB_TAG('K','R','L',' ')}, /* Karelian */
504 {"kru", HB_TAG('K','U','U',' ')}, /* Kurukh */
505 {"ks", HB_TAG('K','S','H',' ')}, /* Kashmiri */
506 {"ksh", HB_TAG('K','S','H','0')}, /* Ripuarian, Kölsch */
507/*{"ksw", HB_TAG('K','R','N',' ')},*/ /* S'gaw Karen (Microsoft fonts?) */
508 {"ksw", HB_TAG('K','S','W',' ')}, /* S'gaw Karen (OpenType spec and SIL fonts) */
509 {"ktb", HB_TAG('K','E','B',' ')}, /* Kebena */
510 {"ktu", HB_TAG('K','O','N',' ')}, /* Kikongo */
511 {"ku", HB_TAG('K','U','R',' ')}, /* Kurdish [macrolanguage] */
512 {"kum", HB_TAG('K','U','M',' ')}, /* Kumyk */
513 {"kv", HB_TAG('K','O','M',' ')}, /* Komi [macrolanguage] */
514 {"kvd", HB_TAG('K','U','I',' ')}, /* Kui (Indonesia) */
515 {"kw", HB_TAG('C','O','R',' ')}, /* Cornish */
516 {"kxc", HB_TAG('K','M','S',' ')}, /* Komso */
517 {"kxu", HB_TAG('K','U','I',' ')}, /* Kui (India) */
518 {"ky", HB_TAG('K','I','R',' ')}, /* Kirghiz/Kyrgyz */
519 {"kyu", HB_TAG('K','Y','U',' ')}, /* Western Kayah */
520 {"la", HB_TAG('L','A','T',' ')}, /* Latin */
521 {"lad", HB_TAG('J','U','D',' ')}, /* Ladino */
522 {"lb", HB_TAG('L','T','Z',' ')}, /* Luxembourgish */
523 {"lbe", HB_TAG('L','A','K',' ')}, /* Lak */
524 {"lbj", HB_TAG('L','D','K',' ')}, /* Ladakhi */
525 {"lez", HB_TAG('L','E','Z',' ')}, /* Lezgi */
526 {"lg", HB_TAG('L','U','G',' ')}, /* Ganda */
527 {"li", HB_TAG('L','I','M',' ')}, /* Limburgan/Limburger/Limburgish */
528 {"lif", HB_TAG('L','M','B',' ')}, /* Limbu */
529 {"lij", HB_TAG('L','I','J',' ')}, /* Ligurian */
530 {"lis", HB_TAG('L','I','S',' ')}, /* Lisu */
531 {"ljp", HB_TAG('L','J','P',' ')}, /* Lampung Api */
532 {"lki", HB_TAG('L','K','I',' ')}, /* Laki */
533 {"lld", HB_TAG('L','A','D',' ')}, /* Ladin */
534 {"lmn", HB_TAG('L','A','M',' ')}, /* Lambani */
535 {"lmo", HB_TAG('L','M','O',' ')}, /* Lombard */
536 {"ln", HB_TAG('L','I','N',' ')}, /* Lingala */
537 {"lo", HB_TAG('L','A','O',' ')}, /* Lao */
538 {"lom", HB_TAG('L','O','M',' ')}, /* Loma */
539 {"lrc", HB_TAG('L','R','C',' ')}, /* Northern Luri */
540 {"lt", HB_TAG('L','T','H',' ')}, /* Lithuanian */
541 {"lu", HB_TAG('L','U','B',' ')}, /* Luba-Katanga */
542 {"lua", HB_TAG('L','U','B',' ')}, /* Luba-Kasai */
543 {"luo", HB_TAG('L','U','O',' ')}, /* Luo (Kenya and Tanzania) */
544 {"lus", HB_TAG('M','I','Z',' ')}, /* Mizo */
545 {"luy", HB_TAG('L','U','H',' ')}, /* Luyia/Oluluyia [macrolanguage] */
546 {"luz", HB_TAG('L','R','C',' ')}, /* Southern Luri */
547 {"lv", HB_TAG('L','V','I',' ')}, /* Latvian */
548 {"lzz", HB_TAG('L','A','Z',' ')}, /* Laz */
549 {"mad", HB_TAG('M','A','D',' ')}, /* Madurese */
550 {"mag", HB_TAG('M','A','G',' ')}, /* Magahi */
551 {"mai", HB_TAG('M','T','H',' ')}, /* Maithili */
552 {"mak", HB_TAG('M','K','R',' ')}, /* Makasar */
553 {"mam", HB_TAG('M','A','M',' ')}, /* Mam */
554 {"man", HB_TAG('M','N','K',' ')}, /* Manding/Mandingo [macrolanguage] */
555 {"mdc", HB_TAG('M','L','E',' ')}, /* Male (Papua New Guinea) */
556 {"mdf", HB_TAG('M','O','K',' ')}, /* Moksha */
557 {"mdr", HB_TAG('M','D','R',' ')}, /* Mandar */
558 {"mdy", HB_TAG('M','L','E',' ')}, /* Male (Ethiopia) */
559 {"men", HB_TAG('M','D','E',' ')}, /* Mende (Sierra Leone) */
560 {"mer", HB_TAG('M','E','R',' ')}, /* Meru */
561 {"mfe", HB_TAG('M','F','E',' ')}, /* Morisyen */
562 {"mg", HB_TAG('M','L','G',' ')}, /* Malagasy [macrolanguage] */
563 {"mh", HB_TAG('M','A','H',' ')}, /* Marshallese */
564 {"mhr", HB_TAG('L','M','A',' ')}, /* Low Mari */
565 {"mi", HB_TAG('M','R','I',' ')}, /* Maori */
566 {"min", HB_TAG('M','I','N',' ')}, /* Minangkabau */
567 {"mk", HB_TAG('M','K','D',' ')}, /* Macedonian */
568 {"mku", HB_TAG('M','N','K',' ')}, /* Konyanka Maninka */
569 {"mkw", HB_TAG('M','K','W',' ')}, /* Kituba (Congo) */
570 {"ml", HB_TAG('M','L','R',' ')}, /* Malayalam */
571 {"mlq", HB_TAG('M','N','K',' ')}, /* Western Maninkakan */
572 {"mn", HB_TAG('M','N','G',' ')}, /* Mongolian [macrolanguage] */
573 {"mnc", HB_TAG('M','C','H',' ')}, /* Manchu */
574 {"mni", HB_TAG('M','N','I',' ')}, /* Manipuri */
575 {"mnk", HB_TAG('M','N','D',' ')}, /* Mandinka */
576 {"mns", HB_TAG('M','A','N',' ')}, /* Mansi */
577 {"mnw", HB_TAG('M','O','N',' ')}, /* Mon */
578 {"mo", HB_TAG('M','O','L',' ')}, /* Moldavian */
579 {"moh", HB_TAG('M','O','H',' ')}, /* Mohawk */
580 {"mos", HB_TAG('M','O','S',' ')}, /* Mossi */
581 {"mpe", HB_TAG('M','A','J',' ')}, /* Majang */
582 {"mr", HB_TAG('M','A','R',' ')}, /* Marathi */
583 {"mrh", HB_TAG('Q','I','N',' ')}, /* Mara Chin */
584 {"mrj", HB_TAG('H','M','A',' ')}, /* High Mari */
585 {"ms", HB_TAG('M','L','Y',' ')}, /* Malay [macrolanguage] */
586 {"msc", HB_TAG('M','N','K',' ')}, /* Sankaran Maninka */
587 {"mt", HB_TAG('M','T','S',' ')}, /* Maltese */
588 {"mtr", HB_TAG('M','A','W',' ')}, /* Mewari */
589 {"mus", HB_TAG('M','U','S',' ')}, /* Creek */
590 {"mve", HB_TAG('M','A','W',' ')}, /* Marwari (Pakistan) */
591 {"mwk", HB_TAG('M','N','K',' ')}, /* Kita Maninkakan */
592 {"mwl", HB_TAG('M','W','L',' ')}, /* Mirandese */
593 {"mwr", HB_TAG('M','A','W',' ')}, /* Marwari [macrolanguage] */
594 {"mww", HB_TAG('M','W','W',' ')}, /* Hmong Daw */
595 {"my", HB_TAG('B','R','M',' ')}, /* Burmese */
596 {"mym", HB_TAG('M','E','N',' ')}, /* Me'en */
597 {"myn", HB_TAG('M','Y','N',' ')}, /* Mayan */
598 {"myq", HB_TAG('M','N','K',' ')}, /* Forest Maninka (retired code) */
599 {"myv", HB_TAG('E','R','Z',' ')}, /* Erzya */
600 {"mzn", HB_TAG('M','Z','N',' ')}, /* Mazanderani */
601 {"na", HB_TAG('N','A','U',' ')}, /* Nauru */
602 {"nag", HB_TAG('N','A','G',' ')}, /* Naga-Assamese */
603 {"nah", HB_TAG('N','A','H',' ')}, /* Nahuatl [family] */
604 {"nap", HB_TAG('N','A','P',' ')}, /* Neapolitan */
605 {"nb", HB_TAG('N','O','R',' ')}, /* Norwegian Bokmål */
606 {"nco", HB_TAG('S','I','B',' ')}, /* Sibe */
607 {"nd", HB_TAG('N','D','B',' ')}, /* [North] Ndebele */
608 {"ndc", HB_TAG('N','D','C',' ')}, /* Ndau */
609 {"nds", HB_TAG('N','D','S',' ')}, /* Low German/Low Saxon */
610 {"ne", HB_TAG('N','E','P',' ')}, /* Nepali */
611 {"new", HB_TAG('N','E','W',' ')}, /* Newari */
612 {"ng", HB_TAG('N','D','G',' ')}, /* Ndonga */
613 {"nga", HB_TAG('N','G','A',' ')}, /* Ngabaka */
614 {"ngl", HB_TAG('L','M','W',' ')}, /* Lomwe */
615 {"ngo", HB_TAG('S','X','T',' ')}, /* Sutu */
616 {"niu", HB_TAG('N','I','U',' ')}, /* Niuean */
617 {"niv", HB_TAG('G','I','L',' ')}, /* Gilyak */
618 {"nl", HB_TAG('N','L','D',' ')}, /* Dutch */
619 {"nn", HB_TAG('N','Y','N',' ')}, /* Norwegian Nynorsk */
620 {"no", HB_TAG('N','O','R',' ')}, /* Norwegian [macrolanguage] */
621 {"nod", HB_TAG('N','T','A',' ')}, /* Northern Thai */
622 {"noe", HB_TAG('N','O','E',' ')}, /* Nimadi */
623 {"nog", HB_TAG('N','O','G',' ')}, /* Nogai */
624 {"nov", HB_TAG('N','O','V',' ')}, /* Novial */
625 {"nqo", HB_TAG('N','K','O',' ')}, /* N'Ko */
626 {"nr", HB_TAG('N','D','B',' ')}, /* [South] Ndebele */
627 {"nsk", HB_TAG('N','A','S',' ')}, /* Naskapi */
628 {"nso", HB_TAG('S','O','T',' ')}, /* [Northern] Sotho */
629 {"nv", HB_TAG('N','A','V',' ')}, /* Navajo */
630 {"ny", HB_TAG('C','H','I',' ')}, /* Chewa/Chichwa/Nyanja */
631 {"nym", HB_TAG('N','Y','M',' ')}, /* Nyamwezi */
632 {"nyn", HB_TAG('N','K','L',' ')}, /* Nyankole */
633 {"oc", HB_TAG('O','C','I',' ')}, /* Occitan (post 1500) */
634 {"oj", HB_TAG('O','J','B',' ')}, /* Ojibwa [macrolanguage] */
635 {"ojs", HB_TAG('O','C','R',' ')}, /* Oji-Cree */
636 {"okm", HB_TAG('K','O','H',' ')}, /* Korean Old Hangul */
637 {"om", HB_TAG('O','R','O',' ')}, /* Oromo [macrolanguage] */
638 {"or", HB_TAG('O','R','I',' ')}, /* Oriya */
639 {"os", HB_TAG('O','S','S',' ')}, /* Ossetian */
640 {"pa", HB_TAG('P','A','N',' ')}, /* Panjabi */
641 {"pag", HB_TAG('P','A','G',' ')}, /* Pangasinan */
642 {"pam", HB_TAG('P','A','M',' ')}, /* Kapampangan/Pampanga */
643 {"pap", HB_TAG('P','A','P','0')}, /* Papiamento */
644 {"pau", HB_TAG('P','A','U',' ')}, /* Palauan */
645 {"pcc", HB_TAG('P','C','C',' ')}, /* Bouyei */
646 {"pcd", HB_TAG('P','C','D',' ')}, /* Picard */
647 {"pce", HB_TAG('P','L','G',' ')}, /* [Ruching] Palaung */
648 {"pck", HB_TAG('Q','I','N',' ')}, /* Paite Chin */
649 {"pdc", HB_TAG('P','D','C',' ')}, /* Pennsylvania German */
650 {"pes", HB_TAG('F','A','R',' ')}, /* Iranian Persian */
651 {"phk", HB_TAG('P','H','K',' ')}, /* Phake */
652 {"pi", HB_TAG('P','A','L',' ')}, /* Pali */
653 {"pih", HB_TAG('P','I','H',' ')}, /* Pitcairn-Norfolk */
654 {"pl", HB_TAG('P','L','K',' ')}, /* Polish */
655 {"pll", HB_TAG('P','L','G',' ')}, /* [Shwe] Palaung */
656 {"plp", HB_TAG('P','A','P',' ')}, /* Palpa */
657 {"pms", HB_TAG('P','M','S',' ')}, /* Piemontese */
658 {"pnb", HB_TAG('P','N','B',' ')}, /* Western Panjabi */
659 {"poh", HB_TAG('P','O','H',' ')}, /* Pocomchi */
660 {"pon", HB_TAG('P','O','N',' ')}, /* Pohnpeian */
661 {"prs", HB_TAG('D','R','I',' ')}, /* Afghan Persian/Dari */
662 {"ps", HB_TAG('P','A','S',' ')}, /* Pashto/Pushto [macrolanguage] */
663 {"pt", HB_TAG('P','T','G',' ')}, /* Portuguese */
664 {"pwo", HB_TAG('P','W','O',' ')}, /* Pwo Western Karen */
665 {"qu", HB_TAG('Q','U','Z',' ')}, /* Quechua [macrolanguage] */
666 {"quc", HB_TAG('Q','U','C',' ')}, /* K'iche'/Quiché */
667 {"quh", HB_TAG('Q','U','H',' ')}, /* Quechua (Bolivia) */
668 {"quz", HB_TAG('Q','U','Z',' ')}, /* Cusco Quechua */
669 {"qvi", HB_TAG('Q','V','I',' ')}, /* Quechua (Ecuador) */
670 {"qwh", HB_TAG('Q','W','H',' ')}, /* Quechua (Peru) */
671 {"raj", HB_TAG('R','A','J',' ')}, /* Rajasthani [macrolanguage] */
672 {"rar", HB_TAG('R','A','R',' ')}, /* Rarotongan */
673 {"rbb", HB_TAG('P','L','G',' ')}, /* Rumai Palaung */
674 {"rej", HB_TAG('R','E','J',' ')}, /* Rejang */
675 {"ria", HB_TAG('R','I','A',' ')}, /* Riang (India) */
676 {"rif", HB_TAG('R','I','F',' ')}, /* Tarifit */
677 {"ril", HB_TAG('R','I','A',' ')}, /* Riang (Myanmar) */
678 {"rit", HB_TAG('R','I','T',' ')}, /* Ritarungo */
679 {"rki", HB_TAG('A','R','K',' ')}, /* Rakhine */
680 {"rkw", HB_TAG('R','K','W',' ')}, /* Arakwal */
681 {"rm", HB_TAG('R','M','S',' ')}, /* Romansh */
682 {"rmy", HB_TAG('R','M','Y',' ')}, /* Vlax Romani */
683 {"rn", HB_TAG('R','U','N',' ')}, /* Rundi */
684 {"ro", HB_TAG('R','O','M',' ')}, /* Romanian */
685 {"rom", HB_TAG('R','O','Y',' ')}, /* Romany [macrolanguage] */
686 {"rtm", HB_TAG('R','T','M',' ')}, /* Rotuman */
687 {"ru", HB_TAG('R','U','S',' ')}, /* Russian */
688 {"rue", HB_TAG('R','S','Y',' ')}, /* Rusyn */
689 {"rup", HB_TAG('R','U','P',' ')}, /* Aromanian/Arumanian/Macedo-Romanian */
690 {"rw", HB_TAG('R','U','A',' ')}, /* Kinyarwanda */
691 {"rwr", HB_TAG('M','A','W',' ')}, /* Marwari (India) */
692 {"sa", HB_TAG('S','A','N',' ')}, /* Sanskrit */
693 {"sah", HB_TAG('Y','A','K',' ')}, /* Yakut */
694 {"sam", HB_TAG('P','A','A',' ')}, /* Palestinian Aramaic */
695 {"sas", HB_TAG('S','A','S',' ')}, /* Sasak */
696 {"sat", HB_TAG('S','A','T',' ')}, /* Santali */
697 {"sc", HB_TAG('S','R','D',' ')}, /* Sardinian [macrolanguage] */
698 {"sck", HB_TAG('S','A','D',' ')}, /* Sadri */
699 {"scn", HB_TAG('S','C','N',' ')}, /* Sicilian */
700 {"sco", HB_TAG('S','C','O',' ')}, /* Scots */
701 {"scs", HB_TAG('S','L','A',' ')}, /* [North] Slavey */
702 {"sd", HB_TAG('S','N','D',' ')}, /* Sindhi */
703 {"se", HB_TAG('N','S','M',' ')}, /* Northern Sami */
704 {"seh", HB_TAG('S','N','A',' ')}, /* Sena */
705 {"sel", HB_TAG('S','E','L',' ')}, /* Selkup */
706 {"sez", HB_TAG('Q','I','N',' ')}, /* Senthang Chin */
707 {"sg", HB_TAG('S','G','O',' ')}, /* Sango */
708 {"sga", HB_TAG('S','G','A',' ')}, /* Old Irish (to 900) */
709 {"sgs", HB_TAG('S','G','S',' ')}, /* Samogitian */
710 {"sgw", HB_TAG('C','H','G',' ')}, /* Sebat Bet Gurage */
711/*{"sgw", HB_TAG('S','G','W',' ')},*/ /* Sebat Bet Gurage (in SIL fonts) */
712 {"shi", HB_TAG('S','H','I',' ')}, /* Tachelhit */
713 {"shn", HB_TAG('S','H','N',' ')}, /* Shan */
714 {"si", HB_TAG('S','N','H',' ')}, /* Sinhala */
715 {"sid", HB_TAG('S','I','D',' ')}, /* Sidamo */
716 {"sjd", HB_TAG('K','S','M',' ')}, /* Kildin Sami */
717 {"sk", HB_TAG('S','K','Y',' ')}, /* Slovak */
718 {"skr", HB_TAG('S','R','K',' ')}, /* Seraiki */
719 {"sl", HB_TAG('S','L','V',' ')}, /* Slovenian */
720 {"sm", HB_TAG('S','M','O',' ')}, /* Samoan */
721 {"sma", HB_TAG('S','S','M',' ')}, /* Southern Sami */
722 {"smj", HB_TAG('L','S','M',' ')}, /* Lule Sami */
723 {"smn", HB_TAG('I','S','M',' ')}, /* Inari Sami */
724 {"sms", HB_TAG('S','K','S',' ')}, /* Skolt Sami */
725 {"sn", HB_TAG('S','N','A','0')}, /* Shona */
726 {"snk", HB_TAG('S','N','K',' ')}, /* Soninke */
727 {"so", HB_TAG('S','M','L',' ')}, /* Somali */
728 {"sop", HB_TAG('S','O','P',' ')}, /* Songe */
729 {"sq", HB_TAG('S','Q','I',' ')}, /* Albanian [macrolanguage] */
730 {"sr", HB_TAG('S','R','B',' ')}, /* Serbian */
731 {"srr", HB_TAG('S','R','R',' ')}, /* Serer */
732 {"ss", HB_TAG('S','W','Z',' ')}, /* Swati */
733 {"st", HB_TAG('S','O','T',' ')}, /* [Southern] Sotho */
734 {"stq", HB_TAG('S','T','Q',' ')}, /* Saterfriesisch */
735 {"stv", HB_TAG('S','I','G',' ')}, /* Silt'e */
736 {"su", HB_TAG('S','U','N',' ')}, /* Sundanese */
737 {"suk", HB_TAG('S','U','K',' ')}, /* Sukama */
738 {"suq", HB_TAG('S','U','R',' ')}, /* Suri */
739 {"sv", HB_TAG('S','V','E',' ')}, /* Swedish */
740 {"sva", HB_TAG('S','V','A',' ')}, /* Svan */
741 {"sw", HB_TAG('S','W','K',' ')}, /* Swahili [macrolanguage] */
742 {"swb", HB_TAG('C','M','R',' ')}, /* Comorian */
743 {"swh", HB_TAG('S','W','K',' ')}, /* Kiswahili/Swahili */
744 {"swv", HB_TAG('M','A','W',' ')}, /* Shekhawati */
745 {"sxu", HB_TAG('S','X','U',' ')}, /* Upper Saxon */
746 {"syc", HB_TAG('S','Y','R',' ')}, /* Classical Syriac */
747 {"syl", HB_TAG('S','Y','L',' ')}, /* Sylheti */
748 {"syr", HB_TAG('S','Y','R',' ')}, /* Syriac [macrolanguage] */
749 {"szl", HB_TAG('S','Z','L',' ')}, /* Silesian */
750 {"ta", HB_TAG('T','A','M',' ')}, /* Tamil */
751 {"tab", HB_TAG('T','A','B',' ')}, /* Tabasaran */
752 {"tcp", HB_TAG('Q','I','N',' ')}, /* Tawr Chin */
753 {"tcy", HB_TAG('T','U','L',' ')}, /* Tulu */
754 {"tcz", HB_TAG('Q','I','N',' ')}, /* Thado Chin */
755 {"tdd", HB_TAG('T','D','D',' ')}, /* Tai Nüa */
756 {"te", HB_TAG('T','E','L',' ')}, /* Telugu */
757 {"tem", HB_TAG('T','M','N',' ')}, /* Temne */
758 {"tet", HB_TAG('T','E','T',' ')}, /* Tetum */
759 {"tg", HB_TAG('T','A','J',' ')}, /* Tajik */
760 {"th", HB_TAG('T','H','A',' ')}, /* Thai */
761 {"ti", HB_TAG('T','G','Y',' ')}, /* Tigrinya */
762 {"tig", HB_TAG('T','G','R',' ')}, /* Tigre */
763 {"tiv", HB_TAG('T','I','V',' ')}, /* Tiv */
764 {"tk", HB_TAG('T','K','M',' ')}, /* Turkmen */
765 {"tl", HB_TAG('T','G','L',' ')}, /* Tagalog */
766 {"tmh", HB_TAG('T','M','H',' ')}, /* Tamashek */
767 {"tn", HB_TAG('T','N','A',' ')}, /* Tswana */
768 {"to", HB_TAG('T','G','N',' ')}, /* Tonga (Tonga Islands) */
769 {"tod", HB_TAG('T','O','D','0')}, /* Toma */
770 {"toi", HB_TAG('T','N','G',' ')}, /* Tonga */
771 {"tpi", HB_TAG('T','P','I',' ')}, /* Tok Pisin */
772 {"tr", HB_TAG('T','R','K',' ')}, /* Turkish */
773 {"tru", HB_TAG('T','U','A',' ')}, /* Turoyo Aramaic */
774 {"ts", HB_TAG('T','S','G',' ')}, /* Tsonga */
775 {"tt", HB_TAG('T','A','T',' ')}, /* Tatar */
776 {"tum", HB_TAG('T','U','M',' ')}, /* Tumbuka */
777 {"tvl", HB_TAG('T','V','L',' ')}, /* Tuvalu */
778 {"tw", HB_TAG('T','W','I',' ')}, /* Twi */
779 {"ty", HB_TAG('T','H','T',' ')}, /* Tahitian */
780 {"tyv", HB_TAG('T','U','V',' ')}, /* Tuvin */
781 {"tyz", HB_TAG('T','Y','Z',' ')}, /* Tày */
782 {"tzm", HB_TAG('T','Z','M',' ')}, /* Central Atlas Tamazight */
783 {"tzo", HB_TAG('T','Z','O',' ')}, /* Tzotzil */
784 {"udm", HB_TAG('U','D','M',' ')}, /* Udmurt */
785 {"ug", HB_TAG('U','Y','G',' ')}, /* Uighur */
786 {"uk", HB_TAG('U','K','R',' ')}, /* Ukrainian */
787 {"umb", HB_TAG('U','M','B',' ')}, /* Umbundu */
788 {"unr", HB_TAG('M','U','N',' ')}, /* Mundari */
789 {"ur", HB_TAG('U','R','D',' ')}, /* Urdu */
790 {"uz", HB_TAG('U','Z','B',' ')}, /* Uzbek [macrolanguage] */
791 {"uzn", HB_TAG('U','Z','B',' ')}, /* Northern Uzbek */
792 {"uzs", HB_TAG('U','Z','B',' ')}, /* Southern Uzbek */
793 {"ve", HB_TAG('V','E','N',' ')}, /* Venda */
794 {"vec", HB_TAG('V','E','C',' ')}, /* Venetian */
795 {"vi", HB_TAG('V','I','T',' ')}, /* Vietnamese */
796 {"vls", HB_TAG('F','L','E',' ')}, /* Vlaams */
797 {"vmw", HB_TAG('M','A','K',' ')}, /* Makhuwa */
798 {"vo", HB_TAG('V','O','L',' ')}, /* Volapük */
799 {"vro", HB_TAG('V','R','O',' ')}, /* Võro */
800 {"wa", HB_TAG('W','L','N',' ')}, /* Walloon */
801 {"war", HB_TAG('W','A','R',' ')}, /* Waray (Philippines) */
802 {"wbm", HB_TAG('W','A',' ',' ')}, /* Wa */
803 {"wbr", HB_TAG('W','A','G',' ')}, /* Wagdi */
804 {"wle", HB_TAG('S','I','G',' ')}, /* Wolane */
805 {"wo", HB_TAG('W','L','F',' ')}, /* Wolof */
806 {"wry", HB_TAG('M','A','W',' ')}, /* Merwari */
807 {"wtm", HB_TAG('W','T','M',' ')}, /* Mewati */
808 {"xal", HB_TAG('K','L','M',' ')}, /* Kalmyk */
809 {"xan", HB_TAG('S','E','K',' ')}, /* Sekota */
810 {"xh", HB_TAG('X','H','S',' ')}, /* Xhosa */
811 {"xjb", HB_TAG('X','J','B',' ')}, /* Minjangbal */
812 {"xog", HB_TAG('X','O','G',' ')}, /* Soga */
813 {"xom", HB_TAG('K','M','O',' ')}, /* Komo (Sudan) */
814 {"xpe", HB_TAG('X','P','E',' ')}, /* Kpelle (Liberia) */
815 {"xsl", HB_TAG('S','S','L',' ')}, /* South Slavey */
816 {"xst", HB_TAG('S','I','G',' ')}, /* Silt'e (retired code) */
817 {"xwo", HB_TAG('T','O','D',' ')}, /* Written Oirat (Todo) */
818 {"yao", HB_TAG('Y','A','O',' ')}, /* Yao */
819 {"yap", HB_TAG('Y','A','P',' ')}, /* Yapese */
820 {"yi", HB_TAG('J','I','I',' ')}, /* Yiddish [macrolanguage] */
821 {"yo", HB_TAG('Y','B','A',' ')}, /* Yoruba */
822 {"yos", HB_TAG('Q','I','N',' ')}, /* Yos, deprecated by IANA in favor of Zou [zom] */
823 {"yso", HB_TAG('N','I','S',' ')}, /* Nisi (China) */
824 {"za", HB_TAG('Z','H','A',' ')}, /* Chuang/Zhuang [macrolanguage] */
825 {"zea", HB_TAG('Z','E','A',' ')}, /* Zeeuws */
826 {"zgh", HB_TAG('Z','G','H',' ')}, /* Standard Morrocan Tamazigh */
827 {"zne", HB_TAG('Z','N','D',' ')}, /* Zande */
828 {"zom", HB_TAG('Q','I','N',' ')}, /* Zou */
829 {"zu", HB_TAG('Z','U','L',' ')}, /* Zulu */
830 {"zum", HB_TAG('L','R','C',' ')}, /* Kumzari */
831 {"zza", HB_TAG('Z','Z','A',' ')}, /* Zazaki */
832
833 /* The corresponding languages IDs for the following IDs are unclear,
834 * overlap, or are architecturally weird. Needs more research. */
835
836/*{"chp", HB_TAG('S','A','Y',' ')},*/ /* Sayisi */
837/*{"cwd", HB_TAG('T','C','R',' ')},*/ /* TH-Cree */
838/*{"emk", HB_TAG('E','M','K',' ')},*/ /* Eastern Maninkakan */
839/*{"krc", HB_TAG('B','A','L',' ')},*/ /* Balkar */
840/*{"??", HB_TAG('B','C','R',' ')},*/ /* Bible Cree */
841/*{"zh?", HB_TAG('C','H','N',' ')},*/ /* Chinese (seen in Microsoft fonts) */
842/*{"ar-Syrc?", HB_TAG('G','A','R',' ')},*/ /* Garshuni */
843/*{"hy?", HB_TAG('H','Y','E','0')},*/ /* Armenian East (ISO 639-3 hye according to Microsoft, but that’s equivalent to ISO 639-1 hy) */
844/*{"ga-Latg?/" HB_TAG('I','R','T',' ')},*/ /* Irish Traditional */
845/*{"krc", HB_TAG('K','A','R',' ')},*/ /* Karachay */
846/*{"ka-Geok?", HB_TAG('K','G','E',' ')},*/ /* Khutsuri Georgian */
847/*{"kca", HB_TAG('K','H','K',' ')},*/ /* Khanty-Kazim */
848/*{"kca", HB_TAG('K','H','S',' ')},*/ /* Khanty-Shurishkar */
849/*{"kca", HB_TAG('K','H','V',' ')},*/ /* Khanty-Vakhi */
850/*{"kqs, kss", HB_TAG('K','I','S',' ')},*/ /* Kisii */
851/*{"lua", HB_TAG('L','U','A',' ')},*/ /* Luba-Lulua */
852/*{"mlq", HB_TAG('M','L','N',' ')},*/ /* Malinke */
853/*{"nso", HB_TAG('N','S','O',' ')},*/ /* Sotho, Northern */
854/*{"??", HB_TAG('M','A','L',' ')},*/ /* Malayalam Traditional */
855/*{"csw", HB_TAG('N','C','R',' ')},*/ /* N-Cree */
856/*{"csw", HB_TAG('N','H','C',' ')},*/ /* Norway House Cree */
857/*{"el-polyton", HB_TAG('P','G','R',' ')},*/ /* Polytonic Greek */
858/*{"bgr, cnh, cnw, czt, sez, tcp, csy, ctd, flm, pck, tcz, zom, cmr, dao, hlt, cka, cnk, mrh, mwg, cbl, cnb, csh", HB_TAG('Q','I','N',' ')},*/ /* Chin */
859/*{"??", HB_TAG('Y','I','C',' ')},*/ /* Yi Classic */
860/*{"zh-Latn-pinyin", HB_TAG('Z','H','P',' ')},*/ /* Chinese Phonetic */
861};
862
863typedef struct {
864 char language[11];
865 hb_tag_t tag;
866} LangTagLong;
867static const LangTagLong ot_languages_zh[] = {
868 /* Store longest-first, if one is a prefix of another. */
869 {"zh-cn", HB_TAG('Z','H','S',' ')}, /* Chinese (China) */
870 {"zh-hk", HB_TAG('Z','H','H',' ')}, /* Chinese (Hong Kong) */
871 {"zh-mo", HB_TAG('Z','H','H',' ')}, /* Chinese (Macao) */
872 {"zh-sg", HB_TAG('Z','H','S',' ')}, /* Chinese (Singapore) */
873 {"zh-tw", HB_TAG('Z','H','T',' ')}, /* Chinese (Taiwan) */
874 {"zh-hans", HB_TAG('Z','H','S',' ')}, /* Chinese (Simplified) */
875 {"zh-hant-hk",HB_TAG('Z','H','H',' ')}, /* Chinese (Hong Kong) */
876 {"zh-hant-mo",HB_TAG('Z','H','H',' ')}, /* Chinese (Macao) */
877 {"zh-hant", HB_TAG('Z','H','T',' ')}, /* Chinese (Traditional) */
878};
879
880static int
881lang_compare_first_component (const void *pa,
882 const void *pb)
883{
884 const char *a = (const char *) pa;
885 const char *b = (const char *) pb;
886 unsigned int da, db;
887 const char *p;
888
889 p = strchr (a, '-');
890 da = p ? (unsigned int) (p - a) : strlen (a);
891
892 p = strchr (b, '-');
893 db = p ? (unsigned int) (p - b) : strlen (b);
894
895 return strncmp (a, b, MAX (da, db));
896}
897
898static hb_bool_t
899lang_matches (const char *lang_str, const char *spec)
900{
901 unsigned int len = strlen (spec);
902
903 return strncmp (lang_str, spec, len) == 0 &&
904 (lang_str[len] == '\0' || lang_str[len] == '-');
905}
906
907hb_tag_t
908hb_ot_tag_from_language (hb_language_t language)
909{
910 const char *lang_str, *s;
911
912 if (language == HB_LANGUAGE_INVALID)
913 return HB_OT_TAG_DEFAULT_LANGUAGE;
914
915 lang_str = hb_language_to_string (language);
916
917 s = strstr (lang_str, "x-hbot");
918 if (s) {
919 char tag[4];
920 int i;
921 s += 6;
922 for (i = 0; i < 4 && ISALNUM (s[i]); i++)
923 tag[i] = TOUPPER (s[i]);
924 if (i) {
925 for (; i < 4; i++)
926 tag[i] = ' ';
927 return HB_TAG (tag[0], tag[1], tag[2], tag[3]);
928 }
929 }
930
931 /*
932 * "fonipa" is a variant tag in BCP-47, meaning the International Phonetic Alphabet.
933 * It can be applied to any language.
934 */
935 if (strstr (lang_str, "-fonipa")) {
936 return HB_TAG('I','P','P','H'); /* Phonetic transcription—IPA conventions */
937 }
938
939 /*
940 * "fonnapa" is a variant tag in BCP-47, meaning the North American Phonetic Alphabet
941 * also known as Americanist Phonetic Notation. It can be applied to any language.
942 */
943 if (strstr (lang_str, "-fonnapa")) {
944 return HB_TAG('A','P','P','H'); /* Phonetic transcription—Americanist conventions */
945 }
946
947 /*
948 * "Syre" is a BCP-47 script tag, meaning the Estrangela variant of the Syriac script.
949 * It can be applied to any language.
950 */
951 if (strstr (lang_str, "-syre")) {
952 return HB_TAG('S','Y','R','E'); /* Estrangela Syriac */
953 }
954
955 /*
956 * "Syrj" is a BCP-47 script tag, meaning the Western variant of the Syriac script.
957 * It can be applied to any language.
958 */
959 if (strstr (lang_str, "-syrj")) {
960 return HB_TAG('S','Y','R','J'); /* Western Syriac */
961 }
962
963 /*
964 * "Syrn" is a BCP-47 script tag, meaning the Eastern variant of the Syriac script.
965 * It can be applied to any language.
966 */
967 if (strstr (lang_str, "-syrn")) {
968 return HB_TAG('S','Y','R','N'); /* Eastern Syriac */
969 }
970
971 /* Find a language matching in the first component */
972 {
973 const LangTag *lang_tag;
974 lang_tag = (LangTag *) bsearch (lang_str, ot_languages,
975 ARRAY_LENGTH (ot_languages), sizeof (LangTag),
976 lang_compare_first_component);
977 if (lang_tag)
978 return lang_tag->tag;
979 }
980
981 /* Otherwise, check the Chinese ones */
982 if (0 == lang_compare_first_component (lang_str, "zh"))
983 {
984 unsigned int i;
985
986 for (i = 0; i < ARRAY_LENGTH (ot_languages_zh); i++)
987 {
988 const LangTagLong *lang_tag;
989 lang_tag = &ot_languages_zh[i];
990 if (lang_matches (lang_str, lang_tag->language))
991 return lang_tag->tag;
992 }
993
994 /* Otherwise just return 'ZHS ' */
995 return HB_TAG('Z','H','S',' ');
996 }
997
998 s = strchr (lang_str, '-');
999 if (!s)
1000 s = lang_str + strlen (lang_str);
1001 if (s - lang_str == 3) {
1002 /* Assume it's ISO-639-3 and upper-case and use it. */
1003 return hb_tag_from_string (lang_str, s - lang_str) & ~0x20202000u;
1004 }
1005
1006 return HB_OT_TAG_DEFAULT_LANGUAGE;
1007}
1008
1009/**
1010 * hb_ot_tag_to_language:
1011 *
1012 *
1013 *
1014 * Return value: (transfer none):
1015 *
1016 * Since: 0.9.2
1017 **/
1018hb_language_t
1019hb_ot_tag_to_language (hb_tag_t tag)
1020{
1021 unsigned int i;
1022
1023 if (tag == HB_OT_TAG_DEFAULT_LANGUAGE)
1024 return nullptr;
1025
1026 /* struct LangTag has only room for 3-letter language tags. */
1027 switch (tag) {
1028 case HB_TAG('A','P','P','H'): /* Phonetic transcription—Americanist conventions */
1029 return hb_language_from_string ("und-fonnapa", -1);
1030 case HB_TAG('I','P','P','H'): /* Phonetic transcription—IPA conventions */
1031 return hb_language_from_string ("und-fonipa", -1);
1032 case HB_TAG('S','Y','R',' '): /* Syriac [macrolanguage] */
1033 return hb_language_from_string ("syr", -1);
1034 case HB_TAG('S','Y','R','E'): /* Estrangela Syriac */
1035 return hb_language_from_string ("und-Syre", -1);
1036 case HB_TAG('S','Y','R','J'): /* Western Syriac */
1037 return hb_language_from_string ("und-Syrj", -1);
1038 case HB_TAG('S','Y','R','N'): /* Eastern Syriac */
1039 return hb_language_from_string ("und-Syrn", -1);
1040 }
1041
1042 for (i = 0; i < ARRAY_LENGTH (ot_languages); i++)
1043 if (ot_languages[i].tag == tag)
1044 return hb_language_from_string (ot_languages[i].language, -1);
1045
1046 /* If tag starts with ZH, it's Chinese */
1047 if ((tag & 0xFFFF0000u) == 0x5A480000u) {
1048 switch (tag) {
1049 case HB_TAG('Z','H','H',' '): return hb_language_from_string ("zh-hk", -1); /* Hong Kong */
1050 case HB_TAG('Z','H','S',' '): return hb_language_from_string ("zh-Hans", -1); /* Simplified */
1051 case HB_TAG('Z','H','T',' '): return hb_language_from_string ("zh-Hant", -1); /* Traditional */
1052 default: break; /* Fall through */
1053 }
1054 }
1055
1056 /* Else return a custom language in the form of "x-hbotABCD" */
1057 {
1058 unsigned char buf[11] = "x-hbot";
1059 buf[6] = tag >> 24;
1060 buf[7] = (tag >> 16) & 0xFF;
1061 buf[8] = (tag >> 8) & 0xFF;
1062 buf[9] = tag & 0xFF;
1063 if (buf[9] == 0x20)
1064 buf[9] = '\0';
1065 buf[10] = '\0';
1066 return hb_language_from_string ((char *) buf, -1);
1067 }
1068}
1069
1070#ifdef MAIN
1071static inline void
1072test_langs_sorted (void)
1073{
1074 for (unsigned int i = 1; i < ARRAY_LENGTH (ot_languages); i++)
1075 {
1076 int c = lang_compare_first_component (ot_languages[i-1].language, ot_languages[i].language);
1077 if (c >= 0)
1078 {
1079 fprintf (stderr, "ot_languages not sorted at index %d: %s %d %s\n",
1080 i, ot_languages[i-1].language, c, ot_languages[i].language);
1081 abort();
1082 }
1083 }
1084}
1085
1086int
1087main (void)
1088{
1089 test_langs_sorted ();
1090 return 0;
1091}
1092
1093#endif
1094