[glib] Use g_unicode_script_to/from_iso15924() if available

This commit is contained in:
Behdad Esfahbod 2011-07-20 21:58:14 -04:00
parent 22fdc66712
commit 26b6024962
1 changed files with 10 additions and 0 deletions

View File

@ -36,6 +36,7 @@
HB_BEGIN_DECLS HB_BEGIN_DECLS
#if !GLIB_CHECK_VERSION(2,29,14)
static const hb_script_t static const hb_script_t
glib_script_to_script[] = glib_script_to_script[] =
{ {
@ -148,10 +149,14 @@ glib_script_to_script[] =
HB_SCRIPT_BRAHMI, HB_SCRIPT_BRAHMI,
HB_SCRIPT_MANDAIC HB_SCRIPT_MANDAIC
}; };
#endif
hb_script_t hb_script_t
hb_glib_script_to_script (GUnicodeScript script) hb_glib_script_to_script (GUnicodeScript script)
{ {
#if GLIB_CHECK_VERSION(2,29,14)
return (hb_script_t) g_unicode_script_to_iso15924 (script);
#else
if (likely ((unsigned int) script < ARRAY_LENGTH (glib_script_to_script))) if (likely ((unsigned int) script < ARRAY_LENGTH (glib_script_to_script)))
return glib_script_to_script[script]; return glib_script_to_script[script];
@ -159,11 +164,15 @@ hb_glib_script_to_script (GUnicodeScript script)
return HB_SCRIPT_INVALID; return HB_SCRIPT_INVALID;
return HB_SCRIPT_UNKNOWN; return HB_SCRIPT_UNKNOWN;
#endif
} }
GUnicodeScript GUnicodeScript
hb_glib_script_from_script (hb_script_t script) hb_glib_script_from_script (hb_script_t script)
{ {
#if GLIB_CHECK_VERSION(2,29,14)
return g_unicode_script_from_iso15924 (script);
#else
unsigned int count = ARRAY_LENGTH (glib_script_to_script); unsigned int count = ARRAY_LENGTH (glib_script_to_script);
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
if (glib_script_to_script[i] == script) if (glib_script_to_script[i] == script)
@ -173,6 +182,7 @@ hb_glib_script_from_script (hb_script_t script)
return G_UNICODE_SCRIPT_INVALID_CODE; return G_UNICODE_SCRIPT_INVALID_CODE;
return G_UNICODE_SCRIPT_UNKNOWN; return G_UNICODE_SCRIPT_UNKNOWN;
#endif
} }