1 #include "config.h"
2 #include <glib.h>
3 #include <glib/gi18n-lib.h>
4 
5 #if defined (HAVE_HARFBUZZ) && defined (HAVE_PANGOFT)
6 #include <hb-ot.h>
7 
8 #include "script-names.h"
9 
10 static struct {
11   GUnicodeScript script;
12   hb_script_t hb_script;
13   const char *name;
14 } scripts[] =
15 {
16   { G_UNICODE_SCRIPT_COMMON, HB_SCRIPT_COMMON,  NULL },
17   { G_UNICODE_SCRIPT_INHERITED, HB_SCRIPT_INHERITED,  NULL },
18   { G_UNICODE_SCRIPT_ARABIC, HB_SCRIPT_ARABIC,  NC_("Script", "Arabic") },
19   { G_UNICODE_SCRIPT_ARMENIAN, HB_SCRIPT_ARMENIAN,  NC_("Script", "Armenian") },
20   { G_UNICODE_SCRIPT_BENGALI, HB_SCRIPT_BENGALI,  NC_("Script", "Bengali") },
21   { G_UNICODE_SCRIPT_BOPOMOFO, HB_SCRIPT_BOPOMOFO,  NC_("Script", "Bopomofo") },
22   { G_UNICODE_SCRIPT_CHEROKEE, HB_SCRIPT_CHEROKEE,  NC_("Script", "Cherokee") },
23   { G_UNICODE_SCRIPT_COPTIC, HB_SCRIPT_COPTIC,  NC_("Script", "Coptic") },
24   { G_UNICODE_SCRIPT_CYRILLIC, HB_SCRIPT_CYRILLIC,  NC_("Script", "Cyrillic") },
25   { G_UNICODE_SCRIPT_DESERET, HB_SCRIPT_DESERET,  NC_("Script", "Deseret") },
26   { G_UNICODE_SCRIPT_DEVANAGARI, HB_SCRIPT_DEVANAGARI,  NC_("Script", "Devanagari") },
27   { G_UNICODE_SCRIPT_ETHIOPIC, HB_SCRIPT_ETHIOPIC,  NC_("Script", "Ethiopic") },
28   { G_UNICODE_SCRIPT_GEORGIAN, HB_SCRIPT_GEORGIAN,  NC_("Script", "Georgian") },
29   { G_UNICODE_SCRIPT_GOTHIC, HB_SCRIPT_GOTHIC,  NC_("Script", "Gothic") },
30   { G_UNICODE_SCRIPT_GREEK, HB_SCRIPT_GREEK,  NC_("Script", "Greek") },
31   { G_UNICODE_SCRIPT_GUJARATI, HB_SCRIPT_GUJARATI,  NC_("Script", "Gujarati") },
32   { G_UNICODE_SCRIPT_GURMUKHI, HB_SCRIPT_GURMUKHI,  NC_("Script", "Gurmukhi") },
33   { G_UNICODE_SCRIPT_HAN, HB_SCRIPT_HAN,  NC_("Script", "Han") },
34   { G_UNICODE_SCRIPT_HANGUL, HB_SCRIPT_HANGUL,  NC_("Script", "Hangul") },
35   { G_UNICODE_SCRIPT_HEBREW, HB_SCRIPT_HEBREW,  NC_("Script", "Hebrew") },
36   { G_UNICODE_SCRIPT_HIRAGANA, HB_SCRIPT_HIRAGANA,  NC_("Script", "Hiragana") },
37   { G_UNICODE_SCRIPT_KANNADA, HB_SCRIPT_KANNADA,  NC_("Script", "Kannada") },
38   { G_UNICODE_SCRIPT_KATAKANA, HB_SCRIPT_KATAKANA,  NC_("Script", "Katakana") },
39   { G_UNICODE_SCRIPT_KHMER, HB_SCRIPT_KHMER,  NC_("Script", "Khmer") },
40   { G_UNICODE_SCRIPT_LAO, HB_SCRIPT_LAO,  NC_("Script", "Lao") },
41   { G_UNICODE_SCRIPT_LATIN, HB_SCRIPT_LATIN,  NC_("Script", "Latin") },
42   { G_UNICODE_SCRIPT_MALAYALAM, HB_SCRIPT_MALAYALAM,  NC_("Script", "Malayalam") },
43   { G_UNICODE_SCRIPT_MONGOLIAN, HB_SCRIPT_MONGOLIAN,  NC_("Script", "Mongolian") },
44   { G_UNICODE_SCRIPT_MYANMAR, HB_SCRIPT_MYANMAR,  NC_("Script", "Myanmar") },
45   { G_UNICODE_SCRIPT_OGHAM, HB_SCRIPT_OGHAM,  NC_("Script", "Ogham") },
46   { G_UNICODE_SCRIPT_OLD_ITALIC, HB_SCRIPT_OLD_ITALIC,  NC_("Script", "Old Italic") },
47   { G_UNICODE_SCRIPT_ORIYA, HB_SCRIPT_ORIYA,  NC_("Script", "Oriya") },
48   { G_UNICODE_SCRIPT_RUNIC, HB_SCRIPT_RUNIC,  NC_("Script", "Runic") },
49   { G_UNICODE_SCRIPT_SINHALA, HB_SCRIPT_SINHALA,  NC_("Script", "Sinhala") },
50   { G_UNICODE_SCRIPT_SYRIAC, HB_SCRIPT_SYRIAC,  NC_("Script", "Syriac") },
51   { G_UNICODE_SCRIPT_TAMIL, HB_SCRIPT_TAMIL,  NC_("Script", "Tamil") },
52   { G_UNICODE_SCRIPT_TELUGU, HB_SCRIPT_TELUGU,  NC_("Script", "Telugu") },
53   { G_UNICODE_SCRIPT_THAANA, HB_SCRIPT_THAANA,  NC_("Script", "Thaana") },
54   { G_UNICODE_SCRIPT_THAI, HB_SCRIPT_THAI,  NC_("Script", "Thai") },
55   { G_UNICODE_SCRIPT_TIBETAN, HB_SCRIPT_TIBETAN,  NC_("Script", "Tibetan") },
56   { G_UNICODE_SCRIPT_CANADIAN_ABORIGINAL, HB_SCRIPT_CANADIAN_ABORIGINAL,  NC_("Script", "Canadian Aboriginal") },
57   { G_UNICODE_SCRIPT_YI, HB_SCRIPT_YI,  NC_("Script", "Yi") },
58   { G_UNICODE_SCRIPT_TAGALOG, HB_SCRIPT_TAGALOG,  NC_("Script", "Tagalog") },
59   { G_UNICODE_SCRIPT_HANUNOO, HB_SCRIPT_HANUNOO,  NC_("Script", "Hanunoo") },
60   { G_UNICODE_SCRIPT_BUHID, HB_SCRIPT_BUHID,  NC_("Script", "Buhid") },
61   { G_UNICODE_SCRIPT_TAGBANWA, HB_SCRIPT_TAGBANWA,  NC_("Script", "Tagbanwa") },
62   { G_UNICODE_SCRIPT_BRAILLE, HB_SCRIPT_BRAILLE,  NC_("Script", "Braille") },
63   { G_UNICODE_SCRIPT_CYPRIOT, HB_SCRIPT_CYPRIOT,  NC_("Script", "Cypriot") },
64   { G_UNICODE_SCRIPT_LIMBU, HB_SCRIPT_LIMBU,  NC_("Script", "Limbu") },
65   { G_UNICODE_SCRIPT_OSMANYA, HB_SCRIPT_OSMANYA,  NC_("Script", "Osmanya") },
66   { G_UNICODE_SCRIPT_SHAVIAN, HB_SCRIPT_SHAVIAN,  NC_("Script", "Shavian") },
67   { G_UNICODE_SCRIPT_LINEAR_B, HB_SCRIPT_LINEAR_B,  NC_("Script", "Linear B") },
68   { G_UNICODE_SCRIPT_TAI_LE, HB_SCRIPT_TAI_LE,  NC_("Script", "Tai Le") },
69   { G_UNICODE_SCRIPT_UGARITIC, HB_SCRIPT_UGARITIC,  NC_("Script", "Ugaritic") },
70   { G_UNICODE_SCRIPT_NEW_TAI_LUE, HB_SCRIPT_NEW_TAI_LUE,  NC_("Script", "New Tai Lue") },
71   { G_UNICODE_SCRIPT_BUGINESE, HB_SCRIPT_BUGINESE,  NC_("Script", "Buginese") },
72   { G_UNICODE_SCRIPT_GLAGOLITIC, HB_SCRIPT_GLAGOLITIC,  NC_("Script", "Glagolitic") },
73   { G_UNICODE_SCRIPT_TIFINAGH, HB_SCRIPT_TIFINAGH,  NC_("Script", "Tifinagh") },
74   { G_UNICODE_SCRIPT_SYLOTI_NAGRI, HB_SCRIPT_SYLOTI_NAGRI,  NC_("Script", "Syloti Nagri") },
75   { G_UNICODE_SCRIPT_OLD_PERSIAN, HB_SCRIPT_OLD_PERSIAN,  NC_("Script", "Old Persian") },
76   { G_UNICODE_SCRIPT_KHAROSHTHI, HB_SCRIPT_KHAROSHTHI,  NC_("Script", "Kharoshthi") },
77   { G_UNICODE_SCRIPT_UNKNOWN, HB_SCRIPT_UNKNOWN,  NC_("Script", "Unknown") },
78   { G_UNICODE_SCRIPT_BALINESE, HB_SCRIPT_BALINESE,  NC_("Script", "Balinese") },
79   { G_UNICODE_SCRIPT_CUNEIFORM, HB_SCRIPT_CUNEIFORM,  NC_("Script", "Cuneiform") },
80   { G_UNICODE_SCRIPT_PHOENICIAN, HB_SCRIPT_PHOENICIAN,  NC_("Script", "Phoenician") },
81   { G_UNICODE_SCRIPT_PHAGS_PA, HB_SCRIPT_PHAGS_PA,  NC_("Script", "Phags-pa") },
82   { G_UNICODE_SCRIPT_NKO, HB_SCRIPT_NKO,  NC_("Script", "N'Ko") },
83   { G_UNICODE_SCRIPT_KAYAH_LI, HB_SCRIPT_KAYAH_LI,  NC_("Script", "Kayah Li") },
84   { G_UNICODE_SCRIPT_LEPCHA, HB_SCRIPT_LEPCHA,  NC_("Script", "Lepcha") },
85   { G_UNICODE_SCRIPT_REJANG, HB_SCRIPT_REJANG,  NC_("Script", "Rejang") },
86   { G_UNICODE_SCRIPT_SUNDANESE, HB_SCRIPT_SUNDANESE,  NC_("Script", "Sundanese") },
87   { G_UNICODE_SCRIPT_SAURASHTRA, HB_SCRIPT_SAURASHTRA,  NC_("Script", "Saurashtra") },
88   { G_UNICODE_SCRIPT_CHAM, HB_SCRIPT_CHAM,  NC_("Script", "Cham") },
89   { G_UNICODE_SCRIPT_OL_CHIKI, HB_SCRIPT_OL_CHIKI,  NC_("Script", "Ol Chiki") },
90   { G_UNICODE_SCRIPT_VAI, HB_SCRIPT_VAI,  NC_("Script", "Vai") },
91   { G_UNICODE_SCRIPT_CARIAN, HB_SCRIPT_CARIAN,  NC_("Script", "Carian") },
92   { G_UNICODE_SCRIPT_LYCIAN, HB_SCRIPT_LYCIAN,  NC_("Script", "Lycian") },
93   { G_UNICODE_SCRIPT_LYDIAN, HB_SCRIPT_LYDIAN,  NC_("Script", "Lydian") },
94   { G_UNICODE_SCRIPT_AVESTAN, HB_SCRIPT_AVESTAN,  NC_("Script", "Avestan") },
95   { G_UNICODE_SCRIPT_BAMUM, HB_SCRIPT_BAMUM,  NC_("Script", "Bamum") },
96   { G_UNICODE_SCRIPT_EGYPTIAN_HIEROGLYPHS, HB_SCRIPT_EGYPTIAN_HIEROGLYPHS,  NC_("Script", "Egyptian Hieroglyphs") },
97   { G_UNICODE_SCRIPT_IMPERIAL_ARAMAIC, HB_SCRIPT_IMPERIAL_ARAMAIC,  NC_("Script", "Imperial Aramaic") },
98   { G_UNICODE_SCRIPT_INSCRIPTIONAL_PAHLAVI, HB_SCRIPT_INSCRIPTIONAL_PAHLAVI,  NC_("Script", "Inscriptional Pahlavi") },
99   { G_UNICODE_SCRIPT_INSCRIPTIONAL_PARTHIAN, HB_SCRIPT_INSCRIPTIONAL_PARTHIAN,  NC_("Script", "Inscriptional Parthian") },
100   { G_UNICODE_SCRIPT_JAVANESE, HB_SCRIPT_JAVANESE,  NC_("Script", "Javanese") },
101   { G_UNICODE_SCRIPT_KAITHI, HB_SCRIPT_KAITHI,  NC_("Script", "Kaithi") },
102   { G_UNICODE_SCRIPT_LISU, HB_SCRIPT_LISU,  NC_("Script", "Lisu") },
103   { G_UNICODE_SCRIPT_MEETEI_MAYEK, HB_SCRIPT_MEETEI_MAYEK,  NC_("Script", "Meetei Mayek") },
104   { G_UNICODE_SCRIPT_OLD_SOUTH_ARABIAN, HB_SCRIPT_OLD_SOUTH_ARABIAN,  NC_("Script", "Old South Arabian") },
105   { G_UNICODE_SCRIPT_OLD_TURKIC, HB_SCRIPT_OLD_TURKIC,  NC_("Script", "Old Turkic") },
106   { G_UNICODE_SCRIPT_SAMARITAN, HB_SCRIPT_SAMARITAN,  NC_("Script", "Samaritan") },
107   { G_UNICODE_SCRIPT_TAI_THAM, HB_SCRIPT_TAI_THAM,  NC_("Script", "Tai Tham") },
108   { G_UNICODE_SCRIPT_TAI_VIET, HB_SCRIPT_TAI_VIET,  NC_("Script", "Tai Viet") },
109   { G_UNICODE_SCRIPT_BATAK, HB_SCRIPT_BATAK,  NC_("Script", "Batak") },
110   { G_UNICODE_SCRIPT_BRAHMI, HB_SCRIPT_BRAHMI,  NC_("Script", "Brahmi") },
111   { G_UNICODE_SCRIPT_MANDAIC, HB_SCRIPT_MANDAIC,  NC_("Script", "Mandaic") },
112   { G_UNICODE_SCRIPT_CHAKMA, HB_SCRIPT_CHAKMA,  NC_("Script", "Chakma") },
113   { G_UNICODE_SCRIPT_MEROITIC_CURSIVE, HB_SCRIPT_MEROITIC_CURSIVE,  NC_("Script", "Meroitic Cursive") },
114   { G_UNICODE_SCRIPT_MEROITIC_HIEROGLYPHS, HB_SCRIPT_MEROITIC_HIEROGLYPHS,  NC_("Script", "Meroitic Hieroglyphs") },
115   { G_UNICODE_SCRIPT_MIAO, HB_SCRIPT_MIAO,  NC_("Script", "Miao") },
116   { G_UNICODE_SCRIPT_SHARADA, HB_SCRIPT_SHARADA,  NC_("Script", "Sharada") },
117   { G_UNICODE_SCRIPT_SORA_SOMPENG, HB_SCRIPT_SORA_SOMPENG,  NC_("Script", "Sora Sompeng") },
118   { G_UNICODE_SCRIPT_TAKRI, HB_SCRIPT_TAKRI,  NC_("Script", "Takri") },
119   { G_UNICODE_SCRIPT_BASSA_VAH, HB_SCRIPT_BASSA_VAH,  NC_("Script", "Bassa") },
120   { G_UNICODE_SCRIPT_CAUCASIAN_ALBANIAN, HB_SCRIPT_CAUCASIAN_ALBANIAN,  NC_("Script", "Caucasian Albanian") },
121   { G_UNICODE_SCRIPT_DUPLOYAN, HB_SCRIPT_DUPLOYAN,  NC_("Script", "Duployan") },
122   { G_UNICODE_SCRIPT_ELBASAN, HB_SCRIPT_ELBASAN,  NC_("Script", "Elbasan") },
123   { G_UNICODE_SCRIPT_GRANTHA, HB_SCRIPT_GRANTHA,  NC_("Script", "Grantha") },
124   { G_UNICODE_SCRIPT_KHOJKI, HB_SCRIPT_KHOJKI,  NC_("Script", "Khojki") },
125   { G_UNICODE_SCRIPT_KHUDAWADI, HB_SCRIPT_KHUDAWADI,  NC_("Script", "Khudawadi, Sindhi") },
126   { G_UNICODE_SCRIPT_LINEAR_A, HB_SCRIPT_LINEAR_A,  NC_("Script", "Linear A") },
127   { G_UNICODE_SCRIPT_MAHAJANI, HB_SCRIPT_MAHAJANI,  NC_("Script", "Mahajani") },
128   { G_UNICODE_SCRIPT_MANICHAEAN, HB_SCRIPT_MANICHAEAN,  NC_("Script", "Manichaean") },
129   { G_UNICODE_SCRIPT_MENDE_KIKAKUI, HB_SCRIPT_MENDE_KIKAKUI,  NC_("Script", "Mende Kikakui") },
130   { G_UNICODE_SCRIPT_MODI, HB_SCRIPT_MODI,  NC_("Script", "Modi") },
131   { G_UNICODE_SCRIPT_MRO, HB_SCRIPT_MRO,  NC_("Script", "Mro") },
132   { G_UNICODE_SCRIPT_NABATAEAN, HB_SCRIPT_NABATAEAN,  NC_("Script", "Nabataean") },
133   { G_UNICODE_SCRIPT_OLD_NORTH_ARABIAN, HB_SCRIPT_OLD_NORTH_ARABIAN,  NC_("Script", "Old North Arabian") },
134   { G_UNICODE_SCRIPT_OLD_PERMIC, HB_SCRIPT_OLD_PERMIC,  NC_("Script", "Old Permic") },
135   { G_UNICODE_SCRIPT_PAHAWH_HMONG, HB_SCRIPT_PAHAWH_HMONG,  NC_("Script", "Pahawh Hmong") },
136   { G_UNICODE_SCRIPT_PALMYRENE, HB_SCRIPT_PALMYRENE,  NC_("Script", "Palmyrene") },
137   { G_UNICODE_SCRIPT_PAU_CIN_HAU, HB_SCRIPT_PAU_CIN_HAU,  NC_("Script", "Pau Cin Hau") },
138   { G_UNICODE_SCRIPT_PSALTER_PAHLAVI, HB_SCRIPT_PSALTER_PAHLAVI,  NC_("Script", "Psalter Pahlavi") },
139   { G_UNICODE_SCRIPT_SIDDHAM, HB_SCRIPT_SIDDHAM,  NC_("Script", "Siddham") },
140   { G_UNICODE_SCRIPT_TIRHUTA, HB_SCRIPT_TIRHUTA,  NC_("Script", "Tirhuta") },
141   { G_UNICODE_SCRIPT_WARANG_CITI, HB_SCRIPT_WARANG_CITI,  NC_("Script", "Warang Citi") },
142   { G_UNICODE_SCRIPT_AHOM, HB_SCRIPT_AHOM,  NC_("Script", "Ahom") },
143   { G_UNICODE_SCRIPT_ANATOLIAN_HIEROGLYPHS, HB_SCRIPT_ANATOLIAN_HIEROGLYPHS,  NC_("Script", "Anatolian Hieroglyphs") },
144   { G_UNICODE_SCRIPT_HATRAN, HB_SCRIPT_HATRAN,  NC_("Script", "Hatran") },
145   { G_UNICODE_SCRIPT_MULTANI, HB_SCRIPT_MULTANI,  NC_("Script", "Multani") },
146   { G_UNICODE_SCRIPT_OLD_HUNGARIAN, HB_SCRIPT_OLD_HUNGARIAN,  NC_("Script", "Old Hungarian") },
147   { G_UNICODE_SCRIPT_SIGNWRITING, HB_SCRIPT_SIGNWRITING,  NC_("Script", "Signwriting") },
148   { G_UNICODE_SCRIPT_ADLAM, HB_SCRIPT_ADLAM,  NC_("Script", "Adlam") },
149   { G_UNICODE_SCRIPT_BHAIKSUKI, HB_SCRIPT_BHAIKSUKI,  NC_("Script", "Bhaiksuki") },
150   { G_UNICODE_SCRIPT_MARCHEN, HB_SCRIPT_MARCHEN,  NC_("Script", "Marchen") },
151   { G_UNICODE_SCRIPT_NEWA, HB_SCRIPT_NEWA,  NC_("Script", "Newa") },
152   { G_UNICODE_SCRIPT_OSAGE, HB_SCRIPT_OSAGE,  NC_("Script", "Osage") },
153   { G_UNICODE_SCRIPT_TANGUT, HB_SCRIPT_TANGUT,  NC_("Script", "Tangut") },
154   { G_UNICODE_SCRIPT_MASARAM_GONDI, HB_SCRIPT_INVALID,  NC_("Script", "Masaram Gondi") },
155   { G_UNICODE_SCRIPT_NUSHU, HB_SCRIPT_INVALID,  NC_("Script", "Nushu") },
156   { G_UNICODE_SCRIPT_SOYOMBO, HB_SCRIPT_INVALID,  NC_("Script", "Soyombo") },
157   { G_UNICODE_SCRIPT_ZANABAZAR_SQUARE, HB_SCRIPT_INVALID,  NC_("Script", "Zanabazar Square") },
158 };
159 
160 const char *
get_script_name(GUnicodeScript script)161 get_script_name (GUnicodeScript script)
162 {
163   int i;
164 
165   for (i = 0; i < G_N_ELEMENTS (scripts); i++)
166     {
167       if (scripts[i].script == script)
168         return g_dpgettext2 (GETTEXT_PACKAGE, "Script", scripts[i].name);
169     }
170 
171   return NULL;
172 }
173 
174 const char *
get_script_name_for_tag(guint32 tag)175 get_script_name_for_tag (guint32 tag)
176 {
177   int i;
178 
179   for (i = 0; i < G_N_ELEMENTS (scripts); i++)
180     {
181       if (scripts[i].hb_script == hb_script_from_iso15924_tag (tag))
182         return g_dpgettext2 (GETTEXT_PACKAGE, "Script", scripts[i].name);
183     }
184 
185   return NULL;
186 }
187 #endif
188