/* * Copyright (C) 2012 Grigori Goronzy <greg@kinoho.net> * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
return a < b ? -1 : a > b ? +1 : 0;
} staticint
_cmp_pair_11_7_14 (constvoid *_key, constvoid *_item)
{
uint32_t& a = * (uint32_t*) _key;
uint32_t b = (* (uint32_t*) _item) & HB_CODEPOINT_ENCODE3_11_7_14(0x1FFFFFu, 0x1FFFFFu, 0);
return a < b ? -1 : a > b ? +1 : 0;
}
static hb_bool_t
hb_ucd_compose (hb_unicode_funcs_t *ufuncs HB_UNUSED,
hb_codepoint_t a, hb_codepoint_t b, hb_codepoint_t *ab, void *user_data HB_UNUSED)
{ // Hangul is handled algorithmically. if (_hb_ucd_compose_hangul (a, b, ab)) returntrue;
hb_codepoint_t u = 0;
if ((a & 0xFFFFF800u) == 0x0000u && (b & 0xFFFFFF80) == 0x0300u)
{ /* If "a" is small enough and "b" is in the U+0300 range, * the composition data is encoded in a 32bit array sorted
* by "a,b" pair. */
uint32_t k = HB_CODEPOINT_ENCODE3_11_7_14 (a, b, 0); const uint32_t *v = hb_bsearch (k,
_hb_ucd_dm2_u32_map,
ARRAY_LENGTH (_hb_ucd_dm2_u32_map), sizeof (*_hb_ucd_dm2_u32_map),
_cmp_pair_11_7_14); if (likely (!v)) returnfalse;
u = HB_CODEPOINT_DECODE3_11_7_14_3 (*v);
} else
{ /* Otherwise it is stored in a 64bit array sorted by
* "a,b" pair. */
uint64_t k = HB_CODEPOINT_ENCODE3 (a, b, 0); const uint64_t *v = hb_bsearch (k,
_hb_ucd_dm2_u64_map,
ARRAY_LENGTH (_hb_ucd_dm2_u64_map), sizeof (*_hb_ucd_dm2_u64_map),
_cmp_pair); if (likely (!v)) returnfalse;
u = HB_CODEPOINT_DECODE3_3 (*v);
}
if (unlikely (!u)) returnfalse;
*ab = u; returntrue;
}
/* If no data, there's no decomposition. */ if (likely (!i)) returnfalse;
i--;
/* Check if it's a single-character decomposition. */ if (i < ARRAY_LENGTH (_hb_ucd_dm1_p0_map) + ARRAY_LENGTH (_hb_ucd_dm1_p2_map))
{ /* Single-character decompositions currently are only in plane 0 or plane 2. */ if (i < ARRAY_LENGTH (_hb_ucd_dm1_p0_map))
{ /* Plane 0. */
*a = _hb_ucd_dm1_p0_map[i];
} else
{ /* Plane 2. */
i -= ARRAY_LENGTH (_hb_ucd_dm1_p0_map);
*a = 0x20000 | _hb_ucd_dm1_p2_map[i];
}
*b = 0; returntrue;
}
i -= ARRAY_LENGTH (_hb_ucd_dm1_p0_map) + ARRAY_LENGTH (_hb_ucd_dm1_p2_map);
/* Otherwise they are encoded either in a 32bit array or a 64bit array. */ if (i < ARRAY_LENGTH (_hb_ucd_dm2_u32_map))
{ /* 32bit array. */
uint32_t v = _hb_ucd_dm2_u32_map[i];
*a = HB_CODEPOINT_DECODE3_11_7_14_1 (v);
*b = HB_CODEPOINT_DECODE3_11_7_14_2 (v); returntrue;
}
i -= ARRAY_LENGTH (_hb_ucd_dm2_u32_map);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.