提交 4d559cdd 编写于 作者: B Behdad Esfahbod

[icu] Remove big script switch(), rely on reverse-lookup

上级 d18431b4
......@@ -40,140 +40,21 @@ HB_BEGIN_DECLS
hb_script_t
hb_icu_script_to_script (UScriptCode script)
{
if (unlikely (script == USCRIPT_INVALID_CODE))
return HB_SCRIPT_INVALID;
return hb_script_from_string (uscript_getShortName (script));
}
UScriptCode
hb_icu_script_from_script (hb_script_t script)
{
switch ((int) script)
{
#define CHECK_ICU_VERSION(major, minor) \
U_ICU_VERSION_MAJOR_NUM > (major) || (U_ICU_VERSION_MAJOR_NUM == (major) && U_ICU_VERSION_MINOR_NUM >= (minor))
#define MATCH_SCRIPT(C) case HB_SCRIPT_##C: return USCRIPT_##C
#define MATCH_SCRIPT2(C1, C2) case HB_SCRIPT_##C2: return USCRIPT_##C1
MATCH_SCRIPT2(INVALID_CODE, INVALID);
MATCH_SCRIPT (COMMON);
MATCH_SCRIPT (INHERITED);
MATCH_SCRIPT (ARABIC);
MATCH_SCRIPT (ARMENIAN);
MATCH_SCRIPT (BENGALI);
MATCH_SCRIPT (BOPOMOFO);
MATCH_SCRIPT (CHEROKEE);
MATCH_SCRIPT (COPTIC);
MATCH_SCRIPT (CYRILLIC);
MATCH_SCRIPT (DESERET);
MATCH_SCRIPT (DEVANAGARI);
MATCH_SCRIPT (ETHIOPIC);
MATCH_SCRIPT (GEORGIAN);
MATCH_SCRIPT (GOTHIC);
MATCH_SCRIPT (GREEK);
MATCH_SCRIPT (GUJARATI);
MATCH_SCRIPT (GURMUKHI);
MATCH_SCRIPT (HAN);
MATCH_SCRIPT (HANGUL);
MATCH_SCRIPT (HEBREW);
MATCH_SCRIPT (HIRAGANA);
MATCH_SCRIPT (KANNADA);
MATCH_SCRIPT (KATAKANA);
MATCH_SCRIPT (KHMER);
MATCH_SCRIPT (LAO);
MATCH_SCRIPT (LATIN);
MATCH_SCRIPT (MALAYALAM);
MATCH_SCRIPT (MONGOLIAN);
MATCH_SCRIPT (MYANMAR);
MATCH_SCRIPT (OGHAM);
MATCH_SCRIPT (OLD_ITALIC);
MATCH_SCRIPT (ORIYA);
MATCH_SCRIPT (RUNIC);
MATCH_SCRIPT (SINHALA);
MATCH_SCRIPT (SYRIAC);
MATCH_SCRIPT (TAMIL);
MATCH_SCRIPT (TELUGU);
MATCH_SCRIPT (THAANA);
MATCH_SCRIPT (THAI);
MATCH_SCRIPT (TIBETAN);
MATCH_SCRIPT (CANADIAN_ABORIGINAL);
MATCH_SCRIPT (YI);
MATCH_SCRIPT (TAGALOG);
MATCH_SCRIPT (HANUNOO);
MATCH_SCRIPT (BUHID);
MATCH_SCRIPT (TAGBANWA);
/* Unicode-4.0 additions */
MATCH_SCRIPT (BRAILLE);
MATCH_SCRIPT (CYPRIOT);
MATCH_SCRIPT (LIMBU);
MATCH_SCRIPT (OSMANYA);
MATCH_SCRIPT (SHAVIAN);
MATCH_SCRIPT (LINEAR_B);
MATCH_SCRIPT (TAI_LE);
MATCH_SCRIPT (UGARITIC);
/* Unicode-4.1 additions */
MATCH_SCRIPT (NEW_TAI_LUE);
MATCH_SCRIPT (BUGINESE);
MATCH_SCRIPT (GLAGOLITIC);
MATCH_SCRIPT (TIFINAGH);
MATCH_SCRIPT (SYLOTI_NAGRI);
MATCH_SCRIPT (OLD_PERSIAN);
MATCH_SCRIPT (KHAROSHTHI);
/* Unicode-5.0 additions */
MATCH_SCRIPT (UNKNOWN);
MATCH_SCRIPT (BALINESE);
MATCH_SCRIPT (CUNEIFORM);
MATCH_SCRIPT (PHOENICIAN);
MATCH_SCRIPT (PHAGS_PA);
MATCH_SCRIPT (NKO);
/* Unicode-5.1 additions */
MATCH_SCRIPT (KAYAH_LI);
MATCH_SCRIPT (LEPCHA);
MATCH_SCRIPT (REJANG);
MATCH_SCRIPT (SUNDANESE);
MATCH_SCRIPT (SAURASHTRA);
MATCH_SCRIPT (CHAM);
MATCH_SCRIPT (OL_CHIKI);
MATCH_SCRIPT (VAI);
MATCH_SCRIPT (CARIAN);
MATCH_SCRIPT (LYCIAN);
MATCH_SCRIPT (LYDIAN);
/* Unicode-5.2 additions */
MATCH_SCRIPT (AVESTAN);
#if CHECK_ICU_VERSION (4, 4)
MATCH_SCRIPT (BAMUM);
#endif
MATCH_SCRIPT (EGYPTIAN_HIEROGLYPHS);
MATCH_SCRIPT (IMPERIAL_ARAMAIC);
MATCH_SCRIPT (INSCRIPTIONAL_PAHLAVI);
MATCH_SCRIPT (INSCRIPTIONAL_PARTHIAN);
MATCH_SCRIPT (JAVANESE);
MATCH_SCRIPT (KAITHI);
MATCH_SCRIPT2(LANNA, TAI_THAM);
#if CHECK_ICU_VERSION (4, 4)
MATCH_SCRIPT (LISU);
#endif
MATCH_SCRIPT2(MEITEI_MAYEK, MEETEI_MAYEK);
#if CHECK_ICU_VERSION (4, 4)
MATCH_SCRIPT (OLD_SOUTH_ARABIAN);
#endif
MATCH_SCRIPT2(ORKHON, OLD_TURKIC);
MATCH_SCRIPT (SAMARITAN);
MATCH_SCRIPT (TAI_VIET);
/* Unicode-6.0 additions */
MATCH_SCRIPT (BATAK);
MATCH_SCRIPT (BRAHMI);
MATCH_SCRIPT2(MANDAEAN, MANDAIC);
#undef CHECK_ICU_VERSION
#undef MATCH_SCRIPT
#undef MATCH_SCRIPT2
}
if (unlikely (script == HB_SCRIPT_INVALID))
return USCRIPT_INVALID_CODE;
for (unsigned int i = 0; i < USCRIPT_CODE_LIMIT; i++)
if (unlikely (hb_icu_script_to_script ((UScriptCode) i) == script))
return (UScriptCode) i;
return USCRIPT_UNKNOWN;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册