Remove deprecated decompose_compatibility stuff

This commit is contained in:
Behdad Esfahbod 2018-10-09 00:39:42 -04:00
parent eed737f672
commit fc50916589
4 changed files with 3 additions and 120 deletions

View File

@ -328,36 +328,7 @@ hb_glib_unicode_decompose (hb_unicode_funcs_t *ufuncs HB_UNUSED,
return ret;
}
static unsigned int
hb_glib_unicode_decompose_compatibility (hb_unicode_funcs_t *ufuncs HB_UNUSED,
hb_codepoint_t u,
hb_codepoint_t *decomposed,
void *user_data HB_UNUSED)
{
#if GLIB_CHECK_VERSION(2,29,12)
return g_unichar_fully_decompose (u, true, decomposed, HB_UNICODE_MAX_DECOMPOSITION_LEN);
#endif
/* If the user doesn't have GLib >= 2.29.12 we have to perform
* a round trip to UTF-8 and the associated memory management dance. */
gchar utf8[6];
gchar *utf8_decomposed, *c;
gsize utf8_len, utf8_decomposed_len, i;
/* Convert @u to UTF-8 and normalise it in NFKD mode. This performs the compatibility decomposition. */
utf8_len = g_unichar_to_utf8 (u, utf8);
utf8_decomposed = g_utf8_normalize (utf8, utf8_len, G_NORMALIZE_NFKD);
utf8_decomposed_len = g_utf8_strlen (utf8_decomposed, -1);
assert (utf8_decomposed_len <= HB_UNICODE_MAX_DECOMPOSITION_LEN);
for (i = 0, c = utf8_decomposed; i < utf8_decomposed_len; i++, c = g_utf8_next_char (c))
*decomposed++ = g_utf8_get_char (c);
g_free (utf8_decomposed);
return utf8_decomposed_len;
}
#define hb_glib_unicode_decompose_compatibility nullptr
#ifdef HB_USE_ATEXIT

View File

@ -292,39 +292,8 @@ hb_icu_unicode_decompose (hb_unicode_funcs_t *ufuncs HB_UNUSED,
return ret;
}
static unsigned int
hb_icu_unicode_decompose_compatibility (hb_unicode_funcs_t *ufuncs HB_UNUSED,
hb_codepoint_t u,
hb_codepoint_t *decomposed,
void *user_data HB_UNUSED)
{
UChar utf16[2], normalized[2 * HB_UNICODE_MAX_DECOMPOSITION_LEN + 1];
unsigned int len;
int32_t utf32_len;
hb_bool_t err;
UErrorCode icu_err;
#define hb_icu_unicode_decompose_compatibility nullptr
/* Copy @u into a UTF-16 array to be passed to ICU. */
len = 0;
err = false;
U16_APPEND (utf16, len, ARRAY_LENGTH (utf16), u, err);
if (err)
return 0;
/* Normalise the codepoint using NFKD mode. */
icu_err = U_ZERO_ERROR;
len = unorm2_normalize (unorm2_getNFKDInstance (&icu_err), utf16, len, normalized, ARRAY_LENGTH (normalized), &icu_err);
if (U_FAILURE (icu_err))
return 0;
/* Convert the decomposed form from UTF-16 to UTF-32. */
icu_err = U_ZERO_ERROR;
u_strToUTF32 ((UChar32*) decomposed, HB_UNICODE_MAX_DECOMPOSITION_LEN, &utf32_len, normalized, len, &icu_err);
if (U_FAILURE (icu_err))
return 0;
return utf32_len;
}
#ifdef HB_USE_ATEXIT
static void free_static_icu_funcs (void);

View File

@ -224,13 +224,7 @@ hb_ucdn_decompose(hb_unicode_funcs_t *ufuncs HB_UNUSED,
return ucdn_decompose(ab, a, b);
}
static unsigned int
hb_ucdn_decompose_compatibility(hb_unicode_funcs_t *ufuncs HB_UNUSED,
hb_codepoint_t u, hb_codepoint_t *decomposed,
void *user_data HB_UNUSED)
{
return ucdn_compat_decompose(u, decomposed);
}
#define hb_ucdn_decompose_compatibility nullptr
#ifdef HB_USE_ATEXIT

View File

@ -722,7 +722,6 @@ test_unicode_normalization (gconstpointer user_data)
{
hb_unicode_funcs_t *uf = (hb_unicode_funcs_t *) user_data;
gunichar a, b, ab;
hb_codepoint_t decomposed[HB_UNICODE_MAX_DECOMPOSITION_LEN];
/* Test compose() */
@ -785,56 +784,6 @@ test_unicode_normalization (gconstpointer user_data)
g_assert (hb_unicode_decompose (uf, 0xD4CC, &a, &b) && a == 0x1111 && b == 0x1171);
g_assert (hb_unicode_decompose (uf, 0xCE31, &a, &b) && a == 0xCE20 && b == 0x11B8);
g_assert (hb_unicode_decompose (uf, 0xCE20, &a, &b) && a == 0x110E && b == 0x1173);
/* Test decompose_compatibility() */
/* Not decomposable */
g_assert (hb_unicode_decompose_compatibility (uf, 0x0041, decomposed) == 0);
g_assert (hb_unicode_decompose_compatibility (uf, 0x1F632, decomposed) == 0);
/* Singletons */
g_assert (hb_unicode_decompose_compatibility (uf, 0x00B5, decomposed) == 1 && decomposed[0] == 0x03BC);
g_assert (hb_unicode_decompose_compatibility (uf, 0x03D6, decomposed) == 1 && decomposed[0] == 0x03C0);
/* Arabic compatibility */
g_assert (hb_unicode_decompose_compatibility (uf, 0xFB54, decomposed) == 1 && decomposed[0] == 0x067B);
/* Longest decomposition ever */
g_assert (18 <= HB_UNICODE_MAX_DECOMPOSITION_LEN);
g_assert (hb_unicode_decompose_compatibility (uf, 0xFDFA, decomposed) == 18 && decomposed[17] == 0x0645);
/* Note: we deliberately don't test characters that have canonical decompositions but no
* compatibility decomposition against the decompose_compatibility() function as that we
* leave up to implementations (for now). */
/* Spaces */
g_assert (hb_unicode_decompose_compatibility (uf, 0x2002, decomposed) == 1 && decomposed[0] == 0x0020);
g_assert (hb_unicode_decompose_compatibility (uf, 0x2003, decomposed) == 1 && decomposed[0] == 0x0020);
g_assert (hb_unicode_decompose_compatibility (uf, 0x2004, decomposed) == 1 && decomposed[0] == 0x0020);
g_assert (hb_unicode_decompose_compatibility (uf, 0x2005, decomposed) == 1 && decomposed[0] == 0x0020);
g_assert (hb_unicode_decompose_compatibility (uf, 0x2006, decomposed) == 1 && decomposed[0] == 0x0020);
g_assert (hb_unicode_decompose_compatibility (uf, 0x2008, decomposed) == 1 && decomposed[0] == 0x0020);
g_assert (hb_unicode_decompose_compatibility (uf, 0x2009, decomposed) == 1 && decomposed[0] == 0x0020);
g_assert (hb_unicode_decompose_compatibility (uf, 0x200A, decomposed) == 1 && decomposed[0] == 0x0020);
/* Pairs */
g_assert (hb_unicode_decompose_compatibility (uf, 0x0587, decomposed) == 2 &&
decomposed[0] == 0x0565 && decomposed[1] == 0x0582);
g_assert (hb_unicode_decompose_compatibility (uf, 0x2017, decomposed) == 2 &&
decomposed[0] == 0x0020 && decomposed[1] == 0x0333);
g_assert (hb_unicode_decompose_compatibility (uf, 0x2025, decomposed) == 2 &&
decomposed[0] == 0x002E && decomposed[1] == 0x002E);
g_assert (hb_unicode_decompose_compatibility (uf, 0x2033, decomposed) == 2 &&
decomposed[0] == 0x2032 && decomposed[1] == 0x2032);
/* Triples */
g_assert (hb_unicode_decompose_compatibility (uf, 0x2026, decomposed) == 3 &&
decomposed[0] == 0x002E && decomposed[1] == 0x002E && decomposed[2] == 0x002E);
g_assert (hb_unicode_decompose_compatibility (uf, 0x2034, decomposed) == 3 &&
decomposed[0] == 0x2032 && decomposed[1] == 0x2032 && decomposed[2] == 0x2032);
g_assert (hb_unicode_decompose_compatibility (uf, 0x213B, decomposed) == 3 &&
decomposed[0] == 0x0046 && decomposed[1] == 0x0041 && decomposed[2] == 0x0058);
}