Inline Unicode callbacks internally

pull/1/head
Behdad Esfahbod 12 years ago
parent 7470315a3e
commit 208f70f055
  1. 2
      src/hb-buffer.cc
  2. 2
      src/hb-fallback-shape.cc
  3. 2
      src/hb-old.cc
  4. 2
      src/hb-ot-shape-complex-misc.cc
  5. 13
      src/hb-ot-shape-normalize.cc
  6. 6
      src/hb-ot-shape-private.hh
  7. 4
      src/hb-ot-shape.cc
  8. 112
      src/hb-unicode-private.hh
  9. 5
      src/hb-unicode.cc

@ -456,7 +456,7 @@ hb_buffer_t::guess_properties (void)
/* If script is set to INVALID, guess from buffer contents */
if (props.script == HB_SCRIPT_INVALID) {
for (unsigned int i = 0; i < len; i++) {
hb_script_t script = hb_unicode_script (unicode, info[i].codepoint);
hb_script_t script = unicode->script (info[i].codepoint);
if (likely (script != HB_SCRIPT_COMMON &&
script != HB_SCRIPT_INHERITED &&
script != HB_SCRIPT_UNKNOWN)) {

@ -106,7 +106,7 @@ _hb_fallback_shape (hb_shape_plan_t *shape_plan,
for (unsigned int i = 0; i < count; i++)
{
if (_hb_unicode_is_zero_width (buffer->info[i].codepoint)) {
if (buffer->unicode->is_zero_width (buffer->info[i].codepoint)) {
buffer->info[i].codepoint = space;
buffer->pos[i].x_advance = 0;
buffer->pos[i].y_advance = 0;

@ -94,7 +94,7 @@ hb_old_convertStringToGlyphIndices (HB_Font old_font,
u = string[i];
if (rightToLeft)
u = hb_unicode_mirroring (hb_unicode_funcs_get_default (), u);
u = hb_unicode_funcs_get_default ()->mirroring (u);
hb_font_get_glyph (font, u, 0, &u); /* TODO Variation selectors */

@ -124,7 +124,7 @@ setup_masks_thai (const hb_ot_complex_shaper_t *shaper,
*
* Uniscribe also does so below-marks reordering. Namely, it positions U+0E3A
* after U+0E38 and U+0E39. We do that by modifying the ccc for U+0E3A.
* See _hb_unicode_modified_combining_class (). Lao does NOT have a U+0E3A
* See unicode->modified_combining_class (). Lao does NOT have a U+0E3A
* equivalent.
*/

@ -95,7 +95,7 @@ decompose (hb_font_t *font, hb_buffer_t *buffer,
{
hb_codepoint_t a, b, glyph;
if (!hb_unicode_decompose (buffer->unicode, ab, &a, &b) ||
if (!buffer->unicode->decompose (ab, &a, &b) ||
(b && !hb_font_get_glyph (font, b, 0, &glyph)))
return false;
@ -131,7 +131,7 @@ decompose_compatibility (hb_font_t *font, hb_buffer_t *buffer,
unsigned int len, i;
hb_codepoint_t decomposed[HB_UNICODE_MAX_DECOMPOSITION_LEN];
len = hb_unicode_decompose_compatibility (buffer->unicode, u, decomposed);
len = buffer->unicode->decompose_compatibility (u, decomposed);
if (!len)
return false;
@ -171,7 +171,7 @@ decompose_multi_char_cluster (hb_font_t *font, hb_buffer_t *buffer,
{
/* TODO Currently if there's a variation-selector we give-up, it's just too hard. */
for (unsigned int i = buffer->idx; i < end; i++)
if (unlikely (_hb_unicode_is_variation_selector (buffer->info[i].codepoint))) {
if (unlikely (buffer->unicode->is_variation_selector (buffer->info[i].codepoint))) {
while (buffer->idx < end)
buffer->next_glyph ();
return;
@ -281,10 +281,9 @@ _hb_ot_shape_normalize (hb_font_t *font, hb_buffer_t *buffer,
(starter == buffer->out_len - 1 ||
_hb_glyph_info_get_modified_combining_class (&buffer->prev()) < _hb_glyph_info_get_modified_combining_class (&buffer->cur())) &&
/* And compose. */
hb_unicode_compose (buffer->unicode,
buffer->out_info[starter].codepoint,
buffer->cur().codepoint,
&composed) &&
buffer->unicode->compose (buffer->out_info[starter].codepoint,
buffer->cur().codepoint,
&composed) &&
/* And the font has glyph for the composite. */
hb_font_get_glyph (font, composed, 0, &glyph))
{

@ -43,9 +43,9 @@ struct hb_ot_shape_plan_t
inline void
_hb_glyph_info_set_unicode_props (hb_glyph_info_t *info, hb_unicode_funcs_t *unicode)
{
info->unicode_props0() = ((unsigned int) hb_unicode_general_category (unicode, info->codepoint)) |
(_hb_unicode_is_zero_width (info->codepoint) ? 0x80 : 0);
info->unicode_props1() = _hb_unicode_modified_combining_class (unicode, info->codepoint);
info->unicode_props0() = ((unsigned int) unicode->general_category (info->codepoint)) |
(unicode->is_zero_width (info->codepoint) ? 0x80 : 0);
info->unicode_props1() = unicode->modified_combining_class (info->codepoint);
}
inline hb_unicode_general_category_t

@ -306,7 +306,7 @@ hb_mirror_chars (hb_ot_shape_context_t *c)
unsigned int count = c->buffer->len;
for (unsigned int i = 0; i < count; i++) {
hb_codepoint_t codepoint = hb_unicode_mirroring (unicode, c->buffer->info[i].codepoint);
hb_codepoint_t codepoint = unicode->mirroring (c->buffer->info[i].codepoint);
if (likely (codepoint == c->buffer->info[i].codepoint))
c->buffer->info[i].mask |= rtlm_mask; /* XXX this should be moved to before setting user-feature masks */
else
@ -327,7 +327,7 @@ hb_map_glyphs (hb_font_t *font,
unsigned int count = buffer->len - 1;
for (buffer->idx = 0; buffer->idx < count;) {
if (unlikely (_hb_unicode_is_variation_selector (buffer->cur(+1).codepoint))) {
if (unlikely (buffer->unicode->is_variation_selector (buffer->cur(+1).codepoint))) {
hb_font_get_glyph (font, buffer->cur().codepoint, buffer->cur(+1).codepoint, &glyph);
buffer->replace_glyphs (2, 1, &glyph);
} else {

@ -143,6 +143,62 @@ HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE
}
HB_INTERNAL unsigned int
modified_combining_class (hb_codepoint_t unicode);
inline hb_bool_t
is_variation_selector (hb_codepoint_t unicode)
{
return unlikely (hb_in_ranges<hb_codepoint_t> (unicode,
0x180B, 0x180D, /* MONGOLIAN FREE VARIATION SELECTOR ONE..THREE */
0xFE00, 0xFE0F, /* VARIATION SELECTOR-1..16 */
0xE0100, 0xE01EF)); /* VARIATION SELECTOR-17..256 */
}
/* Zero-Width invisible characters:
*
* 00AD SOFT HYPHEN
* 034F COMBINING GRAPHEME JOINER
*
* 180E MONGOLIAN VOWEL SEPARATOR
*
* 200B ZERO WIDTH SPACE
* 200C ZERO WIDTH NON-JOINER
* 200D ZERO WIDTH JOINER
* 200E LEFT-TO-RIGHT MARK
* 200F RIGHT-TO-LEFT MARK
*
* 2028 LINE SEPARATOR
*
* 202A LEFT-TO-RIGHT EMBEDDING
* 202B RIGHT-TO-LEFT EMBEDDING
* 202C POP DIRECTIONAL FORMATTING
* 202D LEFT-TO-RIGHT OVERRIDE
* 202E RIGHT-TO-LEFT OVERRIDE
*
* 2060 WORD JOINER
* 2061 FUNCTION APPLICATION
* 2062 INVISIBLE TIMES
* 2063 INVISIBLE SEPARATOR
*
* FEFF ZERO WIDTH NO-BREAK SPACE
*/
inline hb_bool_t
is_zero_width (hb_codepoint_t ch)
{
return ((ch & ~0x007F) == 0x2000 && (hb_in_ranges<hb_codepoint_t> (ch,
0x200B, 0x200F,
0x202A, 0x202E,
0x2060, 0x2064) ||
(ch == 0x2028))) ||
unlikely (ch == 0x0009 ||
ch == 0x00AD ||
ch == 0x034F ||
ch == 0x180E ||
ch == 0xFEFF);
}
struct {
#define HB_UNICODE_FUNC_IMPLEMENT(name) hb_unicode_##name##_func_t name;
HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
@ -176,60 +232,4 @@ extern HB_INTERNAL const hb_unicode_funcs_t _hb_unicode_funcs_nil;
#endif
HB_INTERNAL unsigned int
_hb_unicode_modified_combining_class (hb_unicode_funcs_t *ufuncs,
hb_codepoint_t unicode);
static inline hb_bool_t
_hb_unicode_is_variation_selector (hb_codepoint_t unicode)
{
return unlikely (hb_in_ranges<hb_codepoint_t> (unicode,
0x180B, 0x180D, /* MONGOLIAN FREE VARIATION SELECTOR ONE..THREE */
0xFE00, 0xFE0F, /* VARIATION SELECTOR-1..16 */
0xE0100, 0xE01EF)); /* VARIATION SELECTOR-17..256 */
}
/* Zero-Width invisible characters:
*
* 00AD SOFT HYPHEN
* 034F COMBINING GRAPHEME JOINER
*
* 180E MONGOLIAN VOWEL SEPARATOR
*
* 200B ZERO WIDTH SPACE
* 200C ZERO WIDTH NON-JOINER
* 200D ZERO WIDTH JOINER
* 200E LEFT-TO-RIGHT MARK
* 200F RIGHT-TO-LEFT MARK
*
* 2028 LINE SEPARATOR
*
* 202A LEFT-TO-RIGHT EMBEDDING
* 202B RIGHT-TO-LEFT EMBEDDING
* 202C POP DIRECTIONAL FORMATTING
* 202D LEFT-TO-RIGHT OVERRIDE
* 202E RIGHT-TO-LEFT OVERRIDE
*
* 2060 WORD JOINER
* 2061 FUNCTION APPLICATION
* 2062 INVISIBLE TIMES
* 2063 INVISIBLE SEPARATOR
*
* FEFF ZERO WIDTH NO-BREAK SPACE
*/
static inline hb_bool_t
_hb_unicode_is_zero_width (hb_codepoint_t ch)
{
return ((ch & ~0x007F) == 0x2000 && (hb_in_ranges<hb_codepoint_t> (ch,
0x200B, 0x200F,
0x202A, 0x202E,
0x2060, 0x2064) ||
(ch == 0x2028))) ||
unlikely (ch == 0x0009 ||
ch == 0x00AD ||
ch == 0x034F ||
ch == 0x180E ||
ch == 0xFEFF);
}
#endif /* HB_UNICODE_PRIVATE_HH */

@ -288,10 +288,9 @@ hb_unicode_decompose_compatibility (hb_unicode_funcs_t *ufuncs,
unsigned int
_hb_unicode_modified_combining_class (hb_unicode_funcs_t *ufuncs,
hb_codepoint_t unicode)
hb_unicode_funcs_t::modified_combining_class (hb_codepoint_t unicode)
{
int c = hb_unicode_combining_class (ufuncs, unicode);
int c = combining_class (unicode);
if (unlikely (hb_in_range<int> (c, 27, 33)))
{

Loading…
Cancel
Save