| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright © 2009 Red Hat, Inc. | 2 * Copyright © 2009 Red Hat, Inc. |
| 3 * Copyright © 2011 Google, Inc. | 3 * Copyright © 2011 Google, Inc. |
| 4 * | 4 * |
| 5 * This is part of HarfBuzz, a text shaping library. | 5 * This is part of HarfBuzz, a text shaping library. |
| 6 * | 6 * |
| 7 * Permission is hereby granted, without written agreement and without | 7 * Permission is hereby granted, without written agreement and without |
| 8 * license or royalty fees, to use, copy, modify, and distribute this | 8 * license or royalty fees, to use, copy, modify, and distribute this |
| 9 * software and its documentation for any purpose, provided that the | 9 * software and its documentation for any purpose, provided that the |
| 10 * above copyright notice and the following two paragraphs appear in | 10 * above copyright notice and the following two paragraphs appear in |
| (...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 /*{"??", HB_TAG('M','A','L',' ')},*/ /* Malayalam Traditional */ | 819 /*{"??", HB_TAG('M','A','L',' ')},*/ /* Malayalam Traditional */ |
| 820 /*{"csw", HB_TAG('N','C','R',' ')},*/ /* N-Cree */ | 820 /*{"csw", HB_TAG('N','C','R',' ')},*/ /* N-Cree */ |
| 821 /*{"csw", HB_TAG('N','H','C',' ')},*/ /* Norway House Cree */ | 821 /*{"csw", HB_TAG('N','H','C',' ')},*/ /* Norway House Cree */ |
| 822 /*{"el-polyton", HB_TAG('P','G','R',' ')},*/ /* Polytonic Greek */ | 822 /*{"el-polyton", HB_TAG('P','G','R',' ')},*/ /* Polytonic Greek */ |
| 823 /*{"bgr, cnh, cnw, czt, sez, tcp, csy, ctd, flm, pck, tcz, zom, cmr, dao, hlt, c
ka, cnk, mrh, mwg, cbl, cnb, csh", HB_TAG('Q','I','N',' ')},*/ /* Chin
*/ | 823 /*{"bgr, cnh, cnw, czt, sez, tcp, csy, ctd, flm, pck, tcz, zom, cmr, dao, hlt, c
ka, cnk, mrh, mwg, cbl, cnb, csh", HB_TAG('Q','I','N',' ')},*/ /* Chin
*/ |
| 824 /*{"??", HB_TAG('Y','I','C',' ')},*/ /* Yi Classic */ | 824 /*{"??", HB_TAG('Y','I','C',' ')},*/ /* Yi Classic */ |
| 825 /*{"zh-Latn-pinyin", HB_TAG('Z','H','P',' ')},*/ /* Chinese Phonetic */ | 825 /*{"zh-Latn-pinyin", HB_TAG('Z','H','P',' ')},*/ /* Chinese Phonetic */ |
| 826 }; | 826 }; |
| 827 | 827 |
| 828 typedef struct { | 828 typedef struct { |
| 829 char language[8]; | 829 char language[11]; |
| 830 hb_tag_t tag; | 830 hb_tag_t tag; |
| 831 } LangTagLong; | 831 } LangTagLong; |
| 832 static const LangTagLong ot_languages_zh[] = { | 832 static const LangTagLong ot_languages_zh[] = { |
| 833 /* Store longest-first, if one is a prefix of another. */ |
| 833 {"zh-cn", HB_TAG('Z','H','S',' ')}, /* Chinese (China) */ | 834 {"zh-cn", HB_TAG('Z','H','S',' ')}, /* Chinese (China) */ |
| 834 {"zh-hk", HB_TAG('Z','H','H',' ')}, /* Chinese (Hong Kong) */ | 835 {"zh-hk", HB_TAG('Z','H','H',' ')}, /* Chinese (Hong Kong) */ |
| 835 {"zh-mo",» HB_TAG('Z','H','T',' ')},» /* Chinese (Macao) */ | 836 {"zh-mo",» HB_TAG('Z','H','H',' ')},» /* Chinese (Macao) */ |
| 836 {"zh-sg", HB_TAG('Z','H','S',' ')}, /* Chinese (Singapore) */ | 837 {"zh-sg", HB_TAG('Z','H','S',' ')}, /* Chinese (Singapore) */ |
| 837 {"zh-tw", HB_TAG('Z','H','T',' ')}, /* Chinese (Taiwan) */ | 838 {"zh-tw", HB_TAG('Z','H','T',' ')}, /* Chinese (Taiwan) */ |
| 838 {"zh-hans", HB_TAG('Z','H','S',' ')}, /* Chinese (Simplified) */ | 839 {"zh-hans", HB_TAG('Z','H','S',' ')}, /* Chinese (Simplified) */ |
| 840 {"zh-hant-hk",HB_TAG('Z','H','H',' ')}, /* Chinese (Hong Kong) */ |
| 841 {"zh-hant-mo",HB_TAG('Z','H','H',' ')}, /* Chinese (Macao) */ |
| 839 {"zh-hant", HB_TAG('Z','H','T',' ')}, /* Chinese (Traditional) */ | 842 {"zh-hant", HB_TAG('Z','H','T',' ')}, /* Chinese (Traditional) */ |
| 840 }; | 843 }; |
| 841 | 844 |
| 842 static int | 845 static int |
| 843 lang_compare_first_component (const char *a, | 846 lang_compare_first_component (const char *a, |
| 844 const char *b) | 847 const char *b) |
| 845 { | 848 { |
| 846 unsigned int da, db; | 849 unsigned int da, db; |
| 847 const char *p; | 850 const char *p; |
| 848 | 851 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 882 for (i = 0; i < 4 && ISALPHA (s[i]); i++) | 885 for (i = 0; i < 4 && ISALPHA (s[i]); i++) |
| 883 tag[i] = TOUPPER (s[i]); | 886 tag[i] = TOUPPER (s[i]); |
| 884 if (i) { | 887 if (i) { |
| 885 for (; i < 4; i++) | 888 for (; i < 4; i++) |
| 886 tag[i] = ' '; | 889 tag[i] = ' '; |
| 887 return HB_TAG_CHAR4 (tag); | 890 return HB_TAG_CHAR4 (tag); |
| 888 } | 891 } |
| 889 } | 892 } |
| 890 | 893 |
| 891 /* | 894 /* |
| 892 * The International Phonetic Alphabet is a variant tag in BCP-47, | 895 * "fonipa" is a variant tag in BCP-47, meaning the International Phonetic Alp
habet. |
| 893 * which can be applied to any language. | 896 * It can be applied to any language. |
| 894 */ | 897 */ |
| 895 if (strstr (lang_str, "-fonipa")) { | 898 if (strstr (lang_str, "-fonipa")) { |
| 896 return HB_TAG('I','P','P','H'); /* Phonetic transcription—IPA conventions *
/ | 899 return HB_TAG('I','P','P','H'); /* Phonetic transcription—IPA conventions *
/ |
| 897 } | 900 } |
| 898 | 901 |
| 902 /* |
| 903 * "fonnapa" is a variant tag in BCP-47, meaning the North American Phonetic A
lphabet |
| 904 * also known as Americanist Phonetic Notation. It can be applied to any lang
uage. |
| 905 */ |
| 906 if (strstr (lang_str, "-fonnapa")) { |
| 907 return HB_TAG('A','P','P','H'); /* Phonetic transcription—Americanist conve
ntions */ |
| 908 } |
| 909 |
| 899 /* Find a language matching in the first component */ | 910 /* Find a language matching in the first component */ |
| 900 { | 911 { |
| 901 const LangTag *lang_tag; | 912 const LangTag *lang_tag; |
| 902 lang_tag = (LangTag *) bsearch (lang_str, ot_languages, | 913 lang_tag = (LangTag *) bsearch (lang_str, ot_languages, |
| 903 ARRAY_LENGTH (ot_languages), sizeof (LangTag
), | 914 ARRAY_LENGTH (ot_languages), sizeof (LangTag
), |
| 904 (hb_compare_func_t) lang_compare_first_compo
nent); | 915 (hb_compare_func_t) lang_compare_first_compo
nent); |
| 905 if (lang_tag) | 916 if (lang_tag) |
| 906 return lang_tag->tag; | 917 return lang_tag->tag; |
| 907 } | 918 } |
| 908 | 919 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 960 switch (tag) { | 971 switch (tag) { |
| 961 case HB_TAG('Z','H','H',' '): return hb_language_from_string ("zh-hk", -1)
; /* Hong Kong */ | 972 case HB_TAG('Z','H','H',' '): return hb_language_from_string ("zh-hk", -1)
; /* Hong Kong */ |
| 962 case HB_TAG('Z','H','S',' '): return hb_language_from_string ("zh-Hans", -
1); /* Simplified */ | 973 case HB_TAG('Z','H','S',' '): return hb_language_from_string ("zh-Hans", -
1); /* Simplified */ |
| 963 case HB_TAG('Z','H','T',' '): return hb_language_from_string ("zh-Hant", -
1); /* Traditional */ | 974 case HB_TAG('Z','H','T',' '): return hb_language_from_string ("zh-Hant", -
1); /* Traditional */ |
| 964 default: break; /* Fall through */ | 975 default: break; /* Fall through */ |
| 965 } | 976 } |
| 966 } | 977 } |
| 967 | 978 |
| 968 /* struct LangTag has only room for 3-letter language tags. */ | 979 /* struct LangTag has only room for 3-letter language tags. */ |
| 969 switch (tag) { | 980 switch (tag) { |
| 981 case HB_TAG('A','P','P','H'): /* Phonetic transcription—Americanist conventio
ns */ |
| 982 return hb_language_from_string ("und-fonnapa", -1); |
| 970 case HB_TAG('I','P','P','H'): /* Phonetic transcription—IPA conventions */ | 983 case HB_TAG('I','P','P','H'): /* Phonetic transcription—IPA conventions */ |
| 971 return hb_language_from_string ("und-fonipa", -1); | 984 return hb_language_from_string ("und-fonipa", -1); |
| 972 } | 985 } |
| 973 | 986 |
| 974 /* Else return a custom language in the form of "x-hbotABCD" */ | 987 /* Else return a custom language in the form of "x-hbotABCD" */ |
| 975 { | 988 { |
| 976 unsigned char buf[11] = "x-hbot"; | 989 unsigned char buf[11] = "x-hbot"; |
| 977 buf[6] = tag >> 24; | 990 buf[6] = tag >> 24; |
| 978 buf[7] = (tag >> 16) & 0xFF; | 991 buf[7] = (tag >> 16) & 0xFF; |
| 979 buf[8] = (tag >> 8) & 0xFF; | 992 buf[8] = (tag >> 8) & 0xFF; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1002 } | 1015 } |
| 1003 | 1016 |
| 1004 int | 1017 int |
| 1005 main (void) | 1018 main (void) |
| 1006 { | 1019 { |
| 1007 test_langs_sorted (); | 1020 test_langs_sorted (); |
| 1008 return 0; | 1021 return 0; |
| 1009 } | 1022 } |
| 1010 | 1023 |
| 1011 #endif | 1024 #endif |
| OLD | NEW |