From 1e7c1fcbc33599faefc32d4a28e5d8506d2c56fa Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 27 Oct 2010 22:48:31 -0400 Subject: [PATCH] Move code around --- src/hb-ot-layout-gpos-private.hh | 59 ++++++++++++++++++++++++++++++++ src/hb-ot-layout.cc | 59 ++------------------------------ src/hb-ot-layout.h | 4 +-- src/hb-ot-shape.cc | 2 +- 4 files changed, 63 insertions(+), 61 deletions(-) diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh index 2cfabf95f..490370962 100644 --- a/src/hb-ot-layout-gpos-private.hh +++ b/src/hb-ot-layout-gpos-private.hh @@ -1472,6 +1472,8 @@ struct GPOS : GSUBGPOS hb_mask_t mask) const { return get_lookup (lookup_index).apply_string (layout, buffer, mask); } + static inline void position_finish (hb_buffer_t *buffer); + inline bool sanitize (hb_sanitize_context_t *c) { TRACE_SANITIZE (); if (unlikely (!GSUBGPOS::sanitize (c))) return false; @@ -1482,6 +1484,63 @@ struct GPOS : GSUBGPOS DEFINE_SIZE_STATIC (10); }; +void +GPOS::position_finish (hb_buffer_t *buffer) +{ + unsigned int i, j; + unsigned int len = hb_buffer_get_length (buffer); + hb_glyph_position_t *pos = hb_buffer_get_glyph_positions (buffer); + hb_direction_t direction = buffer->props.direction; + + /* Handle cursive connections: + * First handle all chain-back connections, then handle all chain-forward connections. */ + if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) + { + for (j = 0; j < len; j++) { + if (pos[j].cursive_chain() < 0) + pos[j].y_offset += pos[j + pos[j].cursive_chain()].y_offset; + } + for (i = len; i > 0; i--) { + j = i - 1; + if (pos[j].cursive_chain() > 0) + pos[j].y_offset += pos[j + pos[j].cursive_chain()].y_offset; + } + } + else + { + for (j = 0; j < len; j++) { + if (pos[j].cursive_chain() < 0) + pos[j].x_offset += pos[j + pos[j].cursive_chain()].x_offset; + } + for (i = len; i > 0; i--) { + j = i - 1; + if (pos[j].cursive_chain() > 0) + pos[j].x_offset += pos[j + pos[j].cursive_chain()].x_offset; + } + } + + + /* Handle attachments */ + for (i = 0; i < len; i++) + if (pos[i].back()) + { + unsigned int back = i - pos[i].back(); + pos[i].x_offset += pos[back].x_offset; + pos[i].y_offset += pos[back].y_offset; + + if (HB_DIRECTION_IS_BACKWARD (buffer->props.direction)) + for (j = back + 1; j < i + 1; j++) { + pos[i].x_offset += pos[j].x_advance; + pos[i].y_offset += pos[j].y_advance; + } + else + for (j = back; j < i; j++) { + pos[i].x_offset -= pos[j].x_advance; + pos[i].y_offset -= pos[j].y_advance; + } + } +} + /* Out-of-class implementation for methods recursing */ diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index 98004e931..fb6914d61 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -447,64 +447,9 @@ hb_ot_layout_position_lookup (hb_font_t *font, } void -hb_ot_layout_position_finish (hb_font_t *font HB_UNUSED, - hb_face_t *face HB_UNUSED, - hb_buffer_t *buffer) +hb_ot_layout_position_finish (hb_buffer_t *buffer) { - unsigned int i, j; - unsigned int len = hb_buffer_get_length (buffer); - hb_glyph_position_t *pos = hb_buffer_get_glyph_positions (buffer); - hb_direction_t direction = buffer->props.direction; - - /* TODO: Vertical */ - - /* Handle cursive connections: - * First handle all chain-back connections, then handle all chain-forward connections. */ - if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) - { - for (j = 0; j < len; j++) { - if (pos[j].cursive_chain() < 0) - pos[j].y_offset += pos[j + pos[j].cursive_chain()].y_offset; - } - for (i = len; i > 0; i--) { - j = i - 1; - if (pos[j].cursive_chain() > 0) - pos[j].y_offset += pos[j + pos[j].cursive_chain()].y_offset; - } - } - else - { - for (j = 0; j < len; j++) { - if (pos[j].cursive_chain() < 0) - pos[j].x_offset += pos[j + pos[j].cursive_chain()].x_offset; - } - for (i = len; i > 0; i--) { - j = i - 1; - if (pos[j].cursive_chain() > 0) - pos[j].x_offset += pos[j + pos[j].cursive_chain()].x_offset; - } - } - - - /* Handle attachments */ - for (i = 0; i < len; i++) - if (pos[i].back()) - { - unsigned int back = i - pos[i].back(); - pos[i].x_offset += pos[back].x_offset; - pos[i].y_offset += pos[back].y_offset; - - if (HB_DIRECTION_IS_BACKWARD (buffer->props.direction)) - for (j = back + 1; j < i + 1; j++) { - pos[i].x_offset += pos[j].x_advance; - pos[i].y_offset += pos[j].y_advance; - } - else - for (j = back; j < i; j++) { - pos[i].x_offset -= pos[j].x_advance; - pos[i].y_offset -= pos[j].y_advance; - } - } + GPOS::position_finish (buffer); } diff --git a/src/hb-ot-layout.h b/src/hb-ot-layout.h index 58c0fbe38..9619eb79f 100644 --- a/src/hb-ot-layout.h +++ b/src/hb-ot-layout.h @@ -188,9 +188,7 @@ hb_ot_layout_position_lookup (hb_font_t *font, /* Should be called after all the position_lookup's are done */ void -hb_ot_layout_position_finish (hb_font_t *font, - hb_face_t *face, - hb_buffer_t *buffer); +hb_ot_layout_position_finish (hb_buffer_t *buffer); HB_END_DECLS diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 06316bc93..a4e568d38 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -121,7 +121,7 @@ hb_ot_position_complex (hb_ot_shape_context_t *c) c->plan->map.position (c->font, c->face, c->buffer); - hb_ot_layout_position_finish (c->font, c->face, c->buffer); + hb_ot_layout_position_finish (c->buffer); c->applied_position_complex = TRUE; return;