#ifndef HB_UNICODE_PRIVATE_HH
#define HB_UNICODE_PRIVATE_HH
#include "hb-private.hh"
#include "hb-object-private.hh"
extern HB_INTERNAL const uint8_t _hb_modified_combining_class[256];
#define HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS \
HB_UNICODE_FUNC_IMPLEMENT (combining_class) \
HB_UNICODE_FUNC_IMPLEMENT (eastasian_width) \
HB_UNICODE_FUNC_IMPLEMENT (general_category) \
HB_UNICODE_FUNC_IMPLEMENT (mirroring) \
HB_UNICODE_FUNC_IMPLEMENT (script) \
HB_UNICODE_FUNC_IMPLEMENT (compose) \
HB_UNICODE_FUNC_IMPLEMENT (decompose) \
HB_UNICODE_FUNC_IMPLEMENT (decompose_compatibility) \
#define HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE \
HB_UNICODE_FUNC_IMPLEMENT (hb_unicode_combining_class_t, combining_class) \
HB_UNICODE_FUNC_IMPLEMENT (unsigned int, eastasian_width) \
HB_UNICODE_FUNC_IMPLEMENT (hb_unicode_general_category_t, general_category) \
HB_UNICODE_FUNC_IMPLEMENT (hb_codepoint_t, mirroring) \
HB_UNICODE_FUNC_IMPLEMENT (hb_script_t, script) \
struct hb_unicode_funcs_t {
hb_object_header_t header;
ASSERT_POD ();
hb_unicode_funcs_t *parent;
bool immutable;
#define HB_UNICODE_FUNC_IMPLEMENT(return_type, name) \
inline return_type name (hb_codepoint_t unicode) { return func.name (this, unicode, user_data.name); }
HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE
#undef HB_UNICODE_FUNC_IMPLEMENT
inline hb_bool_t compose (hb_codepoint_t a, hb_codepoint_t b,
hb_codepoint_t *ab)
{
*ab = 0;
if (unlikely (!a || !b)) return false;
return func.compose (this, a, b, ab, user_data.compose);
}
inline hb_bool_t decompose (hb_codepoint_t ab,
hb_codepoint_t *a, hb_codepoint_t *b)
{
*a = ab; *b = 0;
return func.decompose (this, ab, a, b, user_data.decompose);
}
inline unsigned int decompose_compatibility (hb_codepoint_t u,
hb_codepoint_t *decomposed)
{
unsigned int ret = func.decompose_compatibility (this, u, decomposed, user_data.decompose_compatibility);
if (ret == 1 && u == decomposed[0]) {
decomposed[0] = 0;
return 0;
}
decomposed[ret] = 0;
return ret;
}
unsigned int
modified_combining_class (hb_codepoint_t unicode)
{
if (unlikely (unicode == 0x1037)) unicode = 0x103A;
if (unlikely (unicode == 0x1A60)) return 254;
return _hb_modified_combining_class[combining_class (unicode)];
}
inline hb_bool_t
is_variation_selector (hb_codepoint_t unicode)
{
return unlikely (hb_in_ranges<hb_codepoint_t> (unicode,
0x180B, 0x180D,
0xFE00, 0xFE0F,
0xE0100, 0xE01EF));
}
inline hb_bool_t
is_default_ignorable (hb_codepoint_t ch)
{
hb_codepoint_t plane = ch >> 16;
if (likely (plane == 0))
{
hb_codepoint_t page = ch >> 8;
switch (page) {
case 0x00: return unlikely (ch == 0x00AD);
case 0x03: return unlikely (ch == 0x034F);
case 0x06: return unlikely (ch == 0x061C);
case 0x17: return hb_in_range<hb_codepoint_t> (ch, 0x17B4, 0x17B5);
case 0x18: return hb_in_range<hb_codepoint_t> (ch, 0x180B, 0x180E);
case 0x20: return hb_in_ranges<hb_codepoint_t> (ch, 0x200B, 0x200F,
0x202A, 0x202E,
0x2060, 0x206F);
case 0xFE: return hb_in_range<hb_codepoint_t> (ch, 0xFE00, 0xFE0F) || ch == 0xFEFF;
case 0xFF: return hb_in_range<hb_codepoint_t> (ch, 0xFFF0, 0xFFF8);
default: return false;
}
}
else
{
switch (plane) {
case 0x01: return hb_in_range<hb_codepoint_t> (ch, 0x0001D173, 0x0001D17A);
case 0x0E: return hb_in_range<hb_codepoint_t> (ch, 0x000E0000, 0x000E0FFF);
default: return false;
}
}
}
struct {
#define HB_UNICODE_FUNC_IMPLEMENT(name) hb_unicode_##name##_func_t name;
HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
#undef HB_UNICODE_FUNC_IMPLEMENT
} func;
struct {
#define HB_UNICODE_FUNC_IMPLEMENT(name) void *name;
HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
#undef HB_UNICODE_FUNC_IMPLEMENT
} user_data;
struct {
#define HB_UNICODE_FUNC_IMPLEMENT(name) hb_destroy_func_t name;
HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
#undef HB_UNICODE_FUNC_IMPLEMENT
} destroy;
};
extern HB_INTERNAL const hb_unicode_funcs_t _hb_unicode_funcs_nil;
#define HB_MODIFIED_COMBINING_CLASS_CCC10 22
#define HB_MODIFIED_COMBINING_CLASS_CCC11 15
#define HB_MODIFIED_COMBINING_CLASS_CCC12 16
#define HB_MODIFIED_COMBINING_CLASS_CCC13 17
#define HB_MODIFIED_COMBINING_CLASS_CCC14 23
#define HB_MODIFIED_COMBINING_CLASS_CCC15 18
#define HB_MODIFIED_COMBINING_CLASS_CCC16 19
#define HB_MODIFIED_COMBINING_CLASS_CCC17 20
#define HB_MODIFIED_COMBINING_CLASS_CCC18 21
#define HB_MODIFIED_COMBINING_CLASS_CCC19 14
#define HB_MODIFIED_COMBINING_CLASS_CCC20 24
#define HB_MODIFIED_COMBINING_CLASS_CCC21 12
#define HB_MODIFIED_COMBINING_CLASS_CCC22 25
#define HB_MODIFIED_COMBINING_CLASS_CCC23 13
#define HB_MODIFIED_COMBINING_CLASS_CCC24 10
#define HB_MODIFIED_COMBINING_CLASS_CCC25 11
#define HB_MODIFIED_COMBINING_CLASS_CCC26 26
#define HB_MODIFIED_COMBINING_CLASS_CCC27 28
#define HB_MODIFIED_COMBINING_CLASS_CCC28 29
#define HB_MODIFIED_COMBINING_CLASS_CCC29 30
#define HB_MODIFIED_COMBINING_CLASS_CCC30 31
#define HB_MODIFIED_COMBINING_CLASS_CCC31 32
#define HB_MODIFIED_COMBINING_CLASS_CCC32 33
#define HB_MODIFIED_COMBINING_CLASS_CCC33 27
#define HB_MODIFIED_COMBINING_CLASS_CCC34 34
#define HB_MODIFIED_COMBINING_CLASS_CCC35 35
#define HB_MODIFIED_COMBINING_CLASS_CCC36 36
#define HB_MODIFIED_COMBINING_CLASS_CCC84 0
#define HB_MODIFIED_COMBINING_CLASS_CCC91 0
#define HB_MODIFIED_COMBINING_CLASS_CCC103 3
#define HB_MODIFIED_COMBINING_CLASS_CCC107 107
#define HB_MODIFIED_COMBINING_CLASS_CCC118 118
#define HB_MODIFIED_COMBINING_CLASS_CCC122 122
#define HB_MODIFIED_COMBINING_CLASS_CCC129 129
#define HB_MODIFIED_COMBINING_CLASS_CCC130 130
#define HB_MODIFIED_COMBINING_CLASS_CCC132 132
#define HB_UNICODE_GENERAL_CATEGORY_IS_MARK(gen_cat) \
(FLAG (gen_cat) & \
(FLAG (HB_UNICODE_GENERAL_CATEGORY_SPACING_MARK) | \
FLAG (HB_UNICODE_GENERAL_CATEGORY_ENCLOSING_MARK) | \
FLAG (HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK)))
#endif