X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fhb-glib.cc;h=76e1dfd778e2f6c2ce3494fceb0c09c1a828b60a;hb=9ee27a928a989c71923cef82a9e9828f8e9ca051;hp=7a177e411da49bb33e3fcc63ac2c0446cccdf701;hpb=22fdc66712464bdb02e45eed49e4be57e79b442f;p=framework%2Fuifw%2Fharfbuzz.git diff --git a/src/hb-glib.cc b/src/hb-glib.cc index 7a177e4..76e1dfd 100644 --- a/src/hb-glib.cc +++ b/src/hb-glib.cc @@ -36,6 +36,7 @@ HB_BEGIN_DECLS +#if !GLIB_CHECK_VERSION(2,29,14) static const hb_script_t glib_script_to_script[] = { @@ -148,10 +149,14 @@ glib_script_to_script[] = HB_SCRIPT_BRAHMI, HB_SCRIPT_MANDAIC }; +#endif hb_script_t 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))) return glib_script_to_script[script]; @@ -159,11 +164,15 @@ hb_glib_script_to_script (GUnicodeScript script) return HB_SCRIPT_INVALID; return HB_SCRIPT_UNKNOWN; +#endif } GUnicodeScript 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); for (unsigned int i = 0; i < count; i++) 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_UNKNOWN; +#endif } @@ -234,6 +244,9 @@ hb_glib_unicode_compose (hb_unicode_funcs_t *ufuncs HB_UNUSED, /* We don't ifdef-out the fallback code such that compiler always * sees it and makes sure it's compilable. */ + if (!a || !b) + return FALSE; + gchar utf8[12]; gchar *normalized; gint len; @@ -285,6 +298,16 @@ hb_glib_unicode_decompose (hb_unicode_funcs_t *ufuncs HB_UNUSED, } else if (len == 2) { *a = g_utf8_get_char (normalized); *b = g_utf8_get_char (g_utf8_next_char (normalized)); + /* Here's the ugly part: if ab decomposes to a single character and + * that character decomposes again, we have to detect that and undo + * the second part :-(. */ + gchar *recomposed = g_utf8_normalize (normalized, -1, G_NORMALIZE_NFC); + hb_codepoint_t c = g_utf8_get_char (recomposed); + if (c != ab && c != *a) { + *a = c; + *b = 0; + } + g_free (recomposed); ret = TRUE; } else { /* If decomposed to more than two characters, take the last one,