diff options
author | Behdad Esfahbod <behdad@behdad.org> | 2009-08-10 20:59:25 -0400 |
---|---|---|
committer | Behdad Esfahbod <behdad@behdad.org> | 2009-08-10 20:59:25 -0400 |
commit | dfa2cfce0dac5ba1d9f87aea5ff3ab3ed36be6ce (patch) | |
tree | 96ccddea38eea297a4b50f8deaae5383477e13fd | |
parent | 200ba28b0f0e1b90e5f958960b62b0fe657be3ba (diff) | |
download | pango-dfa2cfce0dac5ba1d9f87aea5ff3ab3ed36be6ce.tar.gz |
[HB] Add hb_buffer_reverse()
-rw-r--r-- | pango/opentype/hb-buffer.c | 32 | ||||
-rw-r--r-- | pango/opentype/hb-buffer.h | 7 |
2 files changed, 36 insertions, 3 deletions
diff --git a/pango/opentype/hb-buffer.c b/pango/opentype/hb-buffer.c index c197b905..890a21bc 100644 --- a/pango/opentype/hb-buffer.c +++ b/pango/opentype/hb-buffer.c @@ -65,7 +65,7 @@ hb_buffer_ensure_separate (hb_buffer_t *buffer, unsigned int size) if (!buffer->positions) buffer->positions = calloc (buffer->allocated, sizeof (buffer->positions[0])); - buffer->out_string = buffer->positions; + buffer->out_string = (hb_internal_glyph_info_t *) buffer->positions; memcpy (buffer->out_string, buffer->in_string, buffer->out_length * sizeof (buffer->out_string[0])); } } @@ -136,7 +136,7 @@ hb_buffer_ensure (hb_buffer_t *buffer, unsigned int size) if (buffer->out_string != buffer->in_string) { buffer->in_string = realloc (buffer->in_string, new_allocated * sizeof (buffer->in_string[0])); - buffer->out_string = buffer->positions; + buffer->out_string = (hb_internal_glyph_info_t *) buffer->positions; } else { @@ -212,7 +212,8 @@ _hb_buffer_swap (hb_buffer_t *buffer) hb_internal_glyph_info_t *tmp_string; tmp_string = buffer->in_string; buffer->in_string = buffer->out_string; - buffer->positions = buffer->out_string = tmp_string; + buffer->out_string = tmp_string; + buffer->positions = (hb_internal_glyph_position_t *) buffer->out_string; } tmp = buffer->in_length; @@ -366,3 +367,28 @@ hb_buffer_get_glyph_positions (hb_buffer_t *buffer) return (hb_glyph_position_t *) buffer->positions; } + + +void +hb_buffer_reverse (hb_buffer_t *buffer) +{ + unsigned int i, j; + + for (i = 0, j = buffer->in_length - 1; i < buffer->in_length / 2; i++, j--) { + hb_internal_glyph_info_t t; + + t = buffer->in_string[i]; + buffer->in_string[i] = buffer->in_string[j]; + buffer->in_string[j] = t; + } + + if (buffer->positions) { + for (i = 0, j = buffer->in_length - 1; i < buffer->in_length / 2; i++, j--) { + hb_internal_glyph_position_t t; + + t = buffer->positions[i]; + buffer->positions[i] = buffer->positions[j]; + buffer->positions[j] = t; + } + } +} diff --git a/pango/opentype/hb-buffer.h b/pango/opentype/hb-buffer.h index 57f56bdd..4240f6ab 100644 --- a/pango/opentype/hb-buffer.h +++ b/pango/opentype/hb-buffer.h @@ -99,6 +99,11 @@ void hb_buffer_ensure (hb_buffer_t *buffer, unsigned int size); +void +hb_buffer_reverse (hb_buffer_t *buffer); + + +/* Filling the buffer in */ void hb_buffer_add_glyph (hb_buffer_t *buffer, @@ -107,6 +112,8 @@ hb_buffer_add_glyph (hb_buffer_t *buffer, unsigned int cluster); +/* Getting glyphs out of the buffer */ + /* Return value valid as long as buffer not modified */ unsigned int hb_buffer_get_len (hb_buffer_t *buffer); |