提交 208f70f0 编写于 作者: B Behdad Esfahbod

Inline Unicode callbacks internally

上级 7470315a
...@@ -456,7 +456,7 @@ hb_buffer_t::guess_properties (void) ...@@ -456,7 +456,7 @@ hb_buffer_t::guess_properties (void)
/* If script is set to INVALID, guess from buffer contents */ /* If script is set to INVALID, guess from buffer contents */
if (props.script == HB_SCRIPT_INVALID) { if (props.script == HB_SCRIPT_INVALID) {
for (unsigned int i = 0; i < len; i++) { 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 && if (likely (script != HB_SCRIPT_COMMON &&
script != HB_SCRIPT_INHERITED && script != HB_SCRIPT_INHERITED &&
script != HB_SCRIPT_UNKNOWN)) { script != HB_SCRIPT_UNKNOWN)) {
......
...@@ -106,7 +106,7 @@ _hb_fallback_shape (hb_shape_plan_t *shape_plan, ...@@ -106,7 +106,7 @@ _hb_fallback_shape (hb_shape_plan_t *shape_plan,
for (unsigned int i = 0; i < count; i++) 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->info[i].codepoint = space;
buffer->pos[i].x_advance = 0; buffer->pos[i].x_advance = 0;
buffer->pos[i].y_advance = 0; buffer->pos[i].y_advance = 0;
......
...@@ -94,7 +94,7 @@ hb_old_convertStringToGlyphIndices (HB_Font old_font, ...@@ -94,7 +94,7 @@ hb_old_convertStringToGlyphIndices (HB_Font old_font,
u = string[i]; u = string[i];
if (rightToLeft) 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 */ 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, ...@@ -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 * 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. * 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. * equivalent.
*/ */
......
...@@ -95,7 +95,7 @@ decompose (hb_font_t *font, hb_buffer_t *buffer, ...@@ -95,7 +95,7 @@ decompose (hb_font_t *font, hb_buffer_t *buffer,
{ {
hb_codepoint_t a, b, glyph; 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))) (b && !hb_font_get_glyph (font, b, 0, &glyph)))
return false; return false;
...@@ -131,7 +131,7 @@ decompose_compatibility (hb_font_t *font, hb_buffer_t *buffer, ...@@ -131,7 +131,7 @@ decompose_compatibility (hb_font_t *font, hb_buffer_t *buffer,
unsigned int len, i; unsigned int len, i;
hb_codepoint_t decomposed[HB_UNICODE_MAX_DECOMPOSITION_LEN]; 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) if (!len)
return false; return false;
...@@ -171,7 +171,7 @@ decompose_multi_char_cluster (hb_font_t *font, hb_buffer_t *buffer, ...@@ -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. */ /* 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++) 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) while (buffer->idx < end)
buffer->next_glyph (); buffer->next_glyph ();
return; return;
...@@ -281,8 +281,7 @@ _hb_ot_shape_normalize (hb_font_t *font, hb_buffer_t *buffer, ...@@ -281,8 +281,7 @@ _hb_ot_shape_normalize (hb_font_t *font, hb_buffer_t *buffer,
(starter == buffer->out_len - 1 || (starter == buffer->out_len - 1 ||
_hb_glyph_info_get_modified_combining_class (&buffer->prev()) < _hb_glyph_info_get_modified_combining_class (&buffer->cur())) && _hb_glyph_info_get_modified_combining_class (&buffer->prev()) < _hb_glyph_info_get_modified_combining_class (&buffer->cur())) &&
/* And compose. */ /* And compose. */
hb_unicode_compose (buffer->unicode, buffer->unicode->compose (buffer->out_info[starter].codepoint,
buffer->out_info[starter].codepoint,
buffer->cur().codepoint, buffer->cur().codepoint,
&composed) && &composed) &&
/* And the font has glyph for the composite. */ /* And the font has glyph for the composite. */
......
...@@ -43,9 +43,9 @@ struct hb_ot_shape_plan_t ...@@ -43,9 +43,9 @@ struct hb_ot_shape_plan_t
inline void inline void
_hb_glyph_info_set_unicode_props (hb_glyph_info_t *info, hb_unicode_funcs_t *unicode) _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)) | info->unicode_props0() = ((unsigned int) unicode->general_category (info->codepoint)) |
(_hb_unicode_is_zero_width (info->codepoint) ? 0x80 : 0); (unicode->is_zero_width (info->codepoint) ? 0x80 : 0);
info->unicode_props1() = _hb_unicode_modified_combining_class (unicode, info->codepoint); info->unicode_props1() = unicode->modified_combining_class (info->codepoint);
} }
inline hb_unicode_general_category_t inline hb_unicode_general_category_t
......
...@@ -306,7 +306,7 @@ hb_mirror_chars (hb_ot_shape_context_t *c) ...@@ -306,7 +306,7 @@ hb_mirror_chars (hb_ot_shape_context_t *c)
unsigned int count = c->buffer->len; unsigned int count = c->buffer->len;
for (unsigned int i = 0; i < count; i++) { 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)) 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 */ c->buffer->info[i].mask |= rtlm_mask; /* XXX this should be moved to before setting user-feature masks */
else else
...@@ -327,7 +327,7 @@ hb_map_glyphs (hb_font_t *font, ...@@ -327,7 +327,7 @@ hb_map_glyphs (hb_font_t *font,
unsigned int count = buffer->len - 1; unsigned int count = buffer->len - 1;
for (buffer->idx = 0; buffer->idx < count;) { 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); hb_font_get_glyph (font, buffer->cur().codepoint, buffer->cur(+1).codepoint, &glyph);
buffer->replace_glyphs (2, 1, &glyph); buffer->replace_glyphs (2, 1, &glyph);
} else { } else {
......
...@@ -143,53 +143,19 @@ HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE ...@@ -143,53 +143,19 @@ HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE
} }
struct { HB_INTERNAL unsigned int
#define HB_UNICODE_FUNC_IMPLEMENT(name) hb_unicode_##name##_func_t name; modified_combining_class (hb_codepoint_t unicode);
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;
};
inline hb_bool_t
#ifdef HAVE_GLIB is_variation_selector (hb_codepoint_t unicode)
extern HB_INTERNAL const hb_unicode_funcs_t _hb_glib_unicode_funcs; {
#define _hb_unicode_funcs_default _hb_glib_unicode_funcs
#elif defined(HAVE_ICU)
extern HB_INTERNAL const hb_unicode_funcs_t _hb_icu_unicode_funcs;
#define _hb_unicode_funcs_default _hb_icu_unicode_funcs
#else
#define HB_UNICODE_FUNCS_NIL 1
extern HB_INTERNAL const hb_unicode_funcs_t _hb_unicode_funcs_nil;
#define _hb_unicode_funcs_default _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, return unlikely (hb_in_ranges<hb_codepoint_t> (unicode,
0x180B, 0x180D, /* MONGOLIAN FREE VARIATION SELECTOR ONE..THREE */ 0x180B, 0x180D, /* MONGOLIAN FREE VARIATION SELECTOR ONE..THREE */
0xFE00, 0xFE0F, /* VARIATION SELECTOR-1..16 */ 0xFE00, 0xFE0F, /* VARIATION SELECTOR-1..16 */
0xE0100, 0xE01EF)); /* VARIATION SELECTOR-17..256 */ 0xE0100, 0xE01EF)); /* VARIATION SELECTOR-17..256 */
} }
/* Zero-Width invisible characters: /* Zero-Width invisible characters:
* *
* 00AD SOFT HYPHEN * 00AD SOFT HYPHEN
* 034F COMBINING GRAPHEME JOINER * 034F COMBINING GRAPHEME JOINER
...@@ -217,9 +183,9 @@ _hb_unicode_is_variation_selector (hb_codepoint_t unicode) ...@@ -217,9 +183,9 @@ _hb_unicode_is_variation_selector (hb_codepoint_t unicode)
* *
* FEFF ZERO WIDTH NO-BREAK SPACE * FEFF ZERO WIDTH NO-BREAK SPACE
*/ */
static inline hb_bool_t inline hb_bool_t
_hb_unicode_is_zero_width (hb_codepoint_t ch) is_zero_width (hb_codepoint_t ch)
{ {
return ((ch & ~0x007F) == 0x2000 && (hb_in_ranges<hb_codepoint_t> (ch, return ((ch & ~0x007F) == 0x2000 && (hb_in_ranges<hb_codepoint_t> (ch,
0x200B, 0x200F, 0x200B, 0x200F,
0x202A, 0x202E, 0x202A, 0x202E,
...@@ -230,6 +196,40 @@ _hb_unicode_is_zero_width (hb_codepoint_t ch) ...@@ -230,6 +196,40 @@ _hb_unicode_is_zero_width (hb_codepoint_t ch)
ch == 0x034F || ch == 0x034F ||
ch == 0x180E || ch == 0x180E ||
ch == 0xFEFF); ch == 0xFEFF);
} }
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;
};
#ifdef HAVE_GLIB
extern HB_INTERNAL const hb_unicode_funcs_t _hb_glib_unicode_funcs;
#define _hb_unicode_funcs_default _hb_glib_unicode_funcs
#elif defined(HAVE_ICU)
extern HB_INTERNAL const hb_unicode_funcs_t _hb_icu_unicode_funcs;
#define _hb_unicode_funcs_default _hb_icu_unicode_funcs
#else
#define HB_UNICODE_FUNCS_NIL 1
extern HB_INTERNAL const hb_unicode_funcs_t _hb_unicode_funcs_nil;
#define _hb_unicode_funcs_default _hb_unicode_funcs_nil
#endif
#endif /* HB_UNICODE_PRIVATE_HH */ #endif /* HB_UNICODE_PRIVATE_HH */
...@@ -288,10 +288,9 @@ hb_unicode_decompose_compatibility (hb_unicode_funcs_t *ufuncs, ...@@ -288,10 +288,9 @@ hb_unicode_decompose_compatibility (hb_unicode_funcs_t *ufuncs,
unsigned int unsigned int
_hb_unicode_modified_combining_class (hb_unicode_funcs_t *ufuncs, hb_unicode_funcs_t::modified_combining_class (hb_codepoint_t unicode)
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))) if (unlikely (hb_in_range<int> (c, 27, 33)))
{ {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册