|
|
@ -33,7 +33,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
#include "hb-unicode-private.hh" |
|
|
|
#include "hb-unicode-private.hh" |
|
|
|
|
|
|
|
|
|
|
|
#include <unicode/uversion.h> |
|
|
|
#include <unicode/uvernum.h> |
|
|
|
#include <unicode/uchar.h> |
|
|
|
#include <unicode/uchar.h> |
|
|
|
#include <unicode/unorm.h> |
|
|
|
#include <unicode/unorm.h> |
|
|
|
#include <unicode/ustring.h> |
|
|
|
#include <unicode/ustring.h> |
|
|
@ -164,6 +164,10 @@ hb_icu_unicode_script (hb_unicode_funcs_t *ufuncs HB_UNUSED, |
|
|
|
return hb_icu_script_to_script (scriptCode); |
|
|
|
return hb_icu_script_to_script (scriptCode); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if U_ICU_VERSION_MAJOR_NUM >= 49 |
|
|
|
|
|
|
|
static const UNormalizer2 *normalizer; |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
static hb_bool_t |
|
|
|
static hb_bool_t |
|
|
|
hb_icu_unicode_compose (hb_unicode_funcs_t *ufuncs HB_UNUSED, |
|
|
|
hb_icu_unicode_compose (hb_unicode_funcs_t *ufuncs HB_UNUSED, |
|
|
|
hb_codepoint_t a, |
|
|
|
hb_codepoint_t a, |
|
|
@ -171,8 +175,17 @@ hb_icu_unicode_compose (hb_unicode_funcs_t *ufuncs HB_UNUSED, |
|
|
|
hb_codepoint_t *ab, |
|
|
|
hb_codepoint_t *ab, |
|
|
|
void *user_data HB_UNUSED) |
|
|
|
void *user_data HB_UNUSED) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!a || !b) |
|
|
|
#if U_ICU_VERSION_MAJOR_NUM >= 49 |
|
|
|
return false; |
|
|
|
{ |
|
|
|
|
|
|
|
UChar32 ret = unorm2_composePair (normalizer, a, b); |
|
|
|
|
|
|
|
if (ret < 0) return false; |
|
|
|
|
|
|
|
*ab = ret; |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* We don't ifdef-out the fallback code such that compiler always
|
|
|
|
|
|
|
|
* sees it and makes sure it's compilable. */ |
|
|
|
|
|
|
|
|
|
|
|
UChar utf16[4], normalized[5]; |
|
|
|
UChar utf16[4], normalized[5]; |
|
|
|
unsigned int len; |
|
|
|
unsigned int len; |
|
|
@ -207,6 +220,32 @@ hb_icu_unicode_decompose (hb_unicode_funcs_t *ufuncs HB_UNUSED, |
|
|
|
hb_codepoint_t *b, |
|
|
|
hb_codepoint_t *b, |
|
|
|
void *user_data HB_UNUSED) |
|
|
|
void *user_data HB_UNUSED) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
#if U_ICU_VERSION_MAJOR_NUM >= 49 |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
UChar decomposed[4]; |
|
|
|
|
|
|
|
int len; |
|
|
|
|
|
|
|
UErrorCode icu_err = U_ZERO_ERROR; |
|
|
|
|
|
|
|
len = unorm2_getRawDecomposition (normalizer, ab, decomposed, |
|
|
|
|
|
|
|
ARRAY_LENGTH (decomposed), &icu_err); |
|
|
|
|
|
|
|
if (U_FAILURE (icu_err) || len < 0) return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
len = u_countChar32 (decomposed, len); |
|
|
|
|
|
|
|
if (len == 1) { |
|
|
|
|
|
|
|
U16_GET_UNSAFE (decomposed, 0, *a); |
|
|
|
|
|
|
|
*b = 0; |
|
|
|
|
|
|
|
return *a != ab; |
|
|
|
|
|
|
|
} else if (len == 2) { |
|
|
|
|
|
|
|
len =0; |
|
|
|
|
|
|
|
U16_NEXT_UNSAFE (decomposed, len, *a); |
|
|
|
|
|
|
|
U16_NEXT_UNSAFE (decomposed, len, *b); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* We don't ifdef-out the fallback code such that compiler always
|
|
|
|
|
|
|
|
* sees it and makes sure it's compilable. */ |
|
|
|
|
|
|
|
|
|
|
|
UChar utf16[2], normalized[2 * HB_UNICODE_MAX_DECOMPOSITION_LEN + 1]; |
|
|
|
UChar utf16[2], normalized[2 * HB_UNICODE_MAX_DECOMPOSITION_LEN + 1]; |
|
|
|
unsigned int len; |
|
|
|
unsigned int len; |
|
|
|
hb_bool_t ret, err; |
|
|
|
hb_bool_t ret, err; |
|
|
@ -306,22 +345,28 @@ hb_icu_unicode_decompose_compatibility (hb_unicode_funcs_t *ufuncs HB_UNUSED, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern HB_INTERNAL const hb_unicode_funcs_t _hb_icu_unicode_funcs; |
|
|
|
hb_unicode_funcs_t * |
|
|
|
const hb_unicode_funcs_t _hb_icu_unicode_funcs = { |
|
|
|
hb_icu_get_unicode_funcs (void) |
|
|
|
HB_OBJECT_HEADER_STATIC, |
|
|
|
{ |
|
|
|
|
|
|
|
static const hb_unicode_funcs_t _hb_icu_unicode_funcs = { |
|
|
|
|
|
|
|
HB_OBJECT_HEADER_STATIC, |
|
|
|
|
|
|
|
|
|
|
|
NULL, /* parent */ |
|
|
|
NULL, /* parent */ |
|
|
|
true, /* immutable */ |
|
|
|
true, /* immutable */ |
|
|
|
{ |
|
|
|
{ |
|
|
|
#define HB_UNICODE_FUNC_IMPLEMENT(name) hb_icu_unicode_##name, |
|
|
|
#define HB_UNICODE_FUNC_IMPLEMENT(name) hb_icu_unicode_##name, |
|
|
|
HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS |
|
|
|
HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS |
|
|
|
#undef HB_UNICODE_FUNC_IMPLEMENT |
|
|
|
#undef HB_UNICODE_FUNC_IMPLEMENT |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
hb_unicode_funcs_t * |
|
|
|
#if U_ICU_VERSION_MAJOR_NUM >= 49 |
|
|
|
hb_icu_get_unicode_funcs (void) |
|
|
|
if (!hb_atomic_ptr_get (&normalizer)) { |
|
|
|
{ |
|
|
|
UErrorCode icu_err = U_ZERO_ERROR; |
|
|
|
|
|
|
|
/* We ignore failure in getNFCInstace(). */ |
|
|
|
|
|
|
|
hb_atomic_ptr_cmpexch (&normalizer, NULL, unorm2_getNFCInstance (&icu_err)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
return const_cast<hb_unicode_funcs_t *> (&_hb_icu_unicode_funcs); |
|
|
|
return const_cast<hb_unicode_funcs_t *> (&_hb_icu_unicode_funcs); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|