diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc index b9623e88008dd060a8b78b1de9a545762370bfd5..db4edce1337052dd21f0d0685ac0e3ac1ef72c42 100644 --- a/src/hb-buffer.cc +++ b/src/hb-buffer.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)) { diff --git a/src/hb-fallback-shape.cc b/src/hb-fallback-shape.cc index 52b46b1d5aced0c63a6a498087139d3fb9cb7bee..ad7c88c25132e3bc149e499ba0fe3ca023931147 100644 --- a/src/hb-fallback-shape.cc +++ b/src/hb-fallback-shape.cc @@ -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; diff --git a/src/hb-old.cc b/src/hb-old.cc index 9d1a0055b9bd4d498842af982ced3fae9803d38b..dffc2067e1597417f01fae7bfdbdcebd2252e448 100644 --- a/src/hb-old.cc +++ b/src/hb-old.cc @@ -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 */ diff --git a/src/hb-ot-shape-complex-misc.cc b/src/hb-ot-shape-complex-misc.cc index a9dda94c995df2103f6df5a01b2e7ceca6c900ba..06b873a1a2de9d5054d444a8f0e965cbe56f4387 100644 --- a/src/hb-ot-shape-complex-misc.cc +++ b/src/hb-ot-shape-complex-misc.cc @@ -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. */ diff --git a/src/hb-ot-shape-normalize.cc b/src/hb-ot-shape-normalize.cc index 17a9ac86fb5cd75c1e7b3c702feda0f5baf416f4..fbfe88b293cf4aab87be14fcfa9b62e68a23854b 100644 --- a/src/hb-ot-shape-normalize.cc +++ b/src/hb-ot-shape-normalize.cc @@ -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)) { diff --git a/src/hb-ot-shape-private.hh b/src/hb-ot-shape-private.hh index 30c7808c7d8ce33fcc9556db12364e3ff7beb2ac..fd45e2db4a3a2b8af220107e52000e2c1d982191 100644 --- a/src/hb-ot-shape-private.hh +++ b/src/hb-ot-shape-private.hh @@ -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 diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 11bc74f6185797f67065297452f19b82ae69cff6..e254f565811fb7cc286ebf2bd39cb468c836a2dd 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -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 { diff --git a/src/hb-unicode-private.hh b/src/hb-unicode-private.hh index 91853928e9032e63637a666c6df1ce6793ab2ccc..14d8131c498a9ddb8dc5c397e1575660aac5e76c 100644 --- a/src/hb-unicode-private.hh +++ b/src/hb-unicode-private.hh @@ -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 (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 (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 (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 (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 */ diff --git a/src/hb-unicode.cc b/src/hb-unicode.cc index a94ea16b39f43245f203fd984b122f554af1a6f9..b1bd147e520fdfeebfb14c46197381db94e58b37 100644 --- a/src/hb-unicode.cc +++ b/src/hb-unicode.cc @@ -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 (c, 27, 33))) {