src/hb-common.h | 2 +- src/hb-icu.cc | 2 +- src/hb-ot-shape-complex-arabic.cc | 8 ++++---- src/hb-ot-shape.cc | 6 ++++-- src/hb-private.hh | 19 +++++++++++++++++++ 5 files changed, 29 insertions(+), 8 deletions(-)
New commits: commit 4a68684654e645882095c1189477146287ce9437 Author: Behdad Esfahbod <[email protected]> Date: Thu Jul 21 00:14:01 2011 -0400 When forming clusters, participate all mark types diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 7a84d9b..a9a8a7a 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -202,8 +202,10 @@ hb_form_clusters (hb_ot_shape_context_t *c) { unsigned int count = c->buffer->len; for (unsigned int i = 1; i < count; i++) - /* TODO: Match other mark types too? */ - if (c->buffer->info[i].general_category() == HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK) + if (FLAG (c->buffer->info[i].general_category()) & + (FLAG (HB_UNICODE_GENERAL_CATEGORY_SPACING_MARK) | + FLAG (HB_UNICODE_GENERAL_CATEGORY_ENCLOSING_MARK) | + FLAG (HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK))) c->buffer->info[i].cluster = c->buffer->info[i - 1].cluster; } commit 5157e12a55f943b7fc5be7dce0b2ee1bcacca6ec Author: Behdad Esfahbod <[email protected]> Date: Thu Jul 21 00:12:33 2011 -0400 Rename HB_UNICODE_GENERAL_CATEGORY_COMBINING_MARK to HB_UNICODE_GENERAL_CATEGORY_SPACING_MARK Spacing_Mark is the current Unicode long-name for this property value. The previous name was wrongly carried from glib. diff --git a/src/hb-common.h b/src/hb-common.h index 9e39cd2..a0ab17e 100644 --- a/src/hb-common.h +++ b/src/hb-common.h @@ -145,7 +145,7 @@ typedef enum HB_UNICODE_GENERAL_CATEGORY_OTHER_LETTER, /* Lo */ HB_UNICODE_GENERAL_CATEGORY_TITLECASE_LETTER, /* Lt */ HB_UNICODE_GENERAL_CATEGORY_UPPERCASE_LETTER, /* Lu */ - HB_UNICODE_GENERAL_CATEGORY_COMBINING_MARK, /* Mc */ + HB_UNICODE_GENERAL_CATEGORY_SPACING_MARK, /* Mc */ HB_UNICODE_GENERAL_CATEGORY_ENCLOSING_MARK, /* Me */ HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK, /* Mn */ HB_UNICODE_GENERAL_CATEGORY_DECIMAL_NUMBER, /* Nd */ diff --git a/src/hb-icu.cc b/src/hb-icu.cc index 384b77d..7b85cd5 100644 --- a/src/hb-icu.cc +++ b/src/hb-icu.cc @@ -109,7 +109,7 @@ hb_icu_unicode_general_category (hb_unicode_funcs_t *ufuncs HB_UNUSED, case U_NON_SPACING_MARK: return HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK; case U_ENCLOSING_MARK: return HB_UNICODE_GENERAL_CATEGORY_ENCLOSING_MARK; - case U_COMBINING_SPACING_MARK: return HB_UNICODE_GENERAL_CATEGORY_COMBINING_MARK; + case U_COMBINING_SPACING_MARK: return HB_UNICODE_GENERAL_CATEGORY_SPACING_MARK; case U_DECIMAL_DIGIT_NUMBER: return HB_UNICODE_GENERAL_CATEGORY_DECIMAL_NUMBER; case U_LETTER_NUMBER: return HB_UNICODE_GENERAL_CATEGORY_LETTER_NUMBER; commit 7b08b0a7f2057937dfc3ab2ec191656bf2386463 Author: Behdad Esfahbod <[email protected]> Date: Wed Jul 20 23:59:07 2011 -0400 Minor diff --git a/src/hb-ot-shape-complex-arabic.cc b/src/hb-ot-shape-complex-arabic.cc index 9720f7a..53e7a9b 100644 --- a/src/hb-ot-shape-complex-arabic.cc +++ b/src/hb-ot-shape-complex-arabic.cc @@ -61,25 +61,25 @@ static unsigned int get_joining_type (hb_codepoint_t u, hb_unicode_general_categ { /* TODO Macroize the magic bit operations */ - if (likely (JOINING_TABLE_FIRST <= u && u <= JOINING_TABLE_LAST)) { + if (likely (hb_codepoint_in_range (u, JOINING_TABLE_FIRST, JOINING_TABLE_LAST))) { unsigned int j_type = joining_table[u - JOINING_TABLE_FIRST]; if (likely (j_type != JOINING_TYPE_X)) return j_type; } /* Mongolian joining data is not in ArabicJoining.txt yet */ - if (unlikely (0x1800 <= u && u <= 0x18AF)) + if (unlikely (hb_codepoint_in_range (u, 0x1800, 0x18AF))) { /* All letters, SIBE SYLLABLE BOUNDARY MARKER, and NIRUGU are D */ if (gen_cat == HB_UNICODE_GENERAL_CATEGORY_OTHER_LETTER || u == 0x1807 || u == 0x180A) return JOINING_TYPE_D; } - if (unlikely ((u & ~(0x200C^0x200D)) == 0x200C)) { + if (unlikely (hb_codepoint_in_range (u, 0x200C, 0x200D))) { return u == 0x200C ? JOINING_TYPE_U : JOINING_TYPE_C; } - return ((1<<gen_cat) & ((1<<HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK)|(1<<HB_UNICODE_GENERAL_CATEGORY_ENCLOSING_MARK)|(1<<HB_UNICODE_GENERAL_CATEGORY_FORMAT))) ? + return (FLAG(gen_cat) & (FLAG(HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK) | FLAG(HB_UNICODE_GENERAL_CATEGORY_ENCLOSING_MARK) | FLAG(HB_UNICODE_GENERAL_CATEGORY_FORMAT))) ? JOINING_TYPE_T : JOINING_TYPE_U; } diff --git a/src/hb-private.hh b/src/hb-private.hh index 1cf11bc..b5745e7 100644 --- a/src/hb-private.hh +++ b/src/hb-private.hh @@ -478,6 +478,25 @@ _hb_trace (const char *what, } +/* Pre-mature optimization: + * Checks for lo <= u <= hi but with an optimization if lo and hi + * are only different in a contiguous set of lower-most bits. + */ +static inline bool +hb_codepoint_in_range (hb_codepoint_t u, hb_codepoint_t lo, hb_codepoint_t hi) +{ + if ( ((lo^hi) & lo) == 0 && + ((lo^hi) & hi) == (lo^hi) && + ((lo^hi) & ((lo^hi) + 1)) == 0 ) + return (u & ~(lo^hi)) == lo; + else + return lo <= u && u <= hi; +} + + +/* Useful for set-operations on small enums */ +#define FLAG(x) (1<<(x)) + HB_END_DECLS #endif /* HB_PRIVATE_HH */ _______________________________________________ HarfBuzz mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/harfbuzz
