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