From 3992b5ec4cb43d114d87ff7ee2b992bcf819c9cd Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 1 Sep 2012 19:20:41 -0400 Subject: [PATCH] Move code around --- src/hb-ot-shape-fallback-private.hh | 5 ++++ src/hb-ot-shape-fallback.cc | 46 +++++++++++++++++++---------- src/hb-ot-shape-private.hh | 6 ++++ src/hb-ot-shape.cc | 4 +++ 4 files changed, 46 insertions(+), 15 deletions(-) diff --git a/src/hb-ot-shape-fallback-private.hh b/src/hb-ot-shape-fallback-private.hh index be96c4f19..5e9cb0617 100644 --- a/src/hb-ot-shape-fallback-private.hh +++ b/src/hb-ot-shape-fallback-private.hh @@ -36,4 +36,9 @@ HB_INTERNAL void _hb_ot_shape_fallback_position (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer); +HB_INTERNAL void _hb_ot_shape_fallback_position_recategorize_marks (const hb_ot_shape_plan_t *plan, + hb_font_t *font, + hb_buffer_t *buffer); + + #endif /* HB_OT_SHAPE_FALLBACK_PRIVATE_HH */ diff --git a/src/hb-ot-shape-fallback.cc b/src/hb-ot-shape-fallback.cc index abacfa3a3..b88fa8307 100644 --- a/src/hb-ot-shape-fallback.cc +++ b/src/hb-ot-shape-fallback.cc @@ -26,21 +26,9 @@ #include "hb-ot-shape-fallback-private.hh" -static void -zero_mark_advances (hb_buffer_t *buffer, - unsigned int start, - unsigned int end) -{ - for (unsigned int i = start; i < end; i++) - if (_hb_glyph_info_get_general_category (&buffer->info[i]) == HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK) - { - buffer->pos[i].x_advance = 0; - buffer->pos[i].y_advance = 0; - } -} - static unsigned int -recategorize_combining_class (unsigned int modified_combining_class) +recategorize_combining_class (hb_codepoint_t u, + unsigned int modified_combining_class) { if (modified_combining_class >= 200) return modified_combining_class; @@ -136,6 +124,34 @@ recategorize_combining_class (unsigned int modified_combining_class) return modified_combining_class; } +void +_hb_ot_shape_fallback_position_recategorize_marks (const hb_ot_shape_plan_t *plan, + hb_font_t *font, + hb_buffer_t *buffer) +{ + unsigned int count = buffer->len; + for (unsigned int i = 0; i < count; i++) + if (_hb_glyph_info_get_general_category (&buffer->info[i]) == HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK) { + unsigned int combining_class = _hb_glyph_info_get_modified_combining_class (&buffer->info[i]); + combining_class = recategorize_combining_class (buffer->info[i].codepoint, combining_class); + _hb_glyph_info_set_modified_combining_class (&buffer->info[i], combining_class); + } +} + + +static void +zero_mark_advances (hb_buffer_t *buffer, + unsigned int start, + unsigned int end) +{ + for (unsigned int i = start; i < end; i++) + if (_hb_glyph_info_get_general_category (&buffer->info[i]) == HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK) + { + buffer->pos[i].x_advance = 0; + buffer->pos[i].y_advance = 0; + } +} + static inline void position_mark (const hb_ot_shape_plan_t *plan, hb_font_t *font, @@ -259,7 +275,7 @@ position_around_base (const hb_ot_shape_plan_t *plan, for (unsigned int i = base + 1; i < end; i++) if (_hb_glyph_info_get_modified_combining_class (&buffer->info[i])) { - unsigned int this_combining_class = recategorize_combining_class (_hb_glyph_info_get_modified_combining_class (&buffer->info[i])); + unsigned int this_combining_class = _hb_glyph_info_get_modified_combining_class (&buffer->info[i]); if (this_combining_class != last_combining_class) cluster_extents = base_extents; diff --git a/src/hb-ot-shape-private.hh b/src/hb-ot-shape-private.hh index f85604554..c4c368db7 100644 --- a/src/hb-ot-shape-private.hh +++ b/src/hb-ot-shape-private.hh @@ -95,6 +95,12 @@ _hb_glyph_info_get_general_category (const hb_glyph_info_t *info) return (hb_unicode_general_category_t) (info->unicode_props0() & 0x7F); } +inline void +_hb_glyph_info_set_modified_combining_class (hb_glyph_info_t *info, unsigned int modified_class) +{ + info->unicode_props1() = modified_class; +} + inline unsigned int _hb_glyph_info_get_modified_combining_class (const hb_glyph_info_t *info) { diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 929406e1b..26b21ce4a 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -345,6 +345,10 @@ hb_ot_substitute_default (hb_ot_shape_context_t *c) hb_ot_shape_setup_masks (c); + /* This is unfortunate to go here, but necessary... */ + if (!hb_ot_layout_has_positioning (c->face)) + _hb_ot_shape_fallback_position_recategorize_marks (c->plan, c->font, c->buffer); + hb_ot_map_glyphs_fast (c->buffer); HB_BUFFER_DEALLOCATE_VAR (c->buffer, glyph_index);