[pango] [HB] Add hb_buffer_reverse()
- From: Behdad Esfahbod <behdad src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [pango] [HB] Add hb_buffer_reverse()
- Date: Tue, 11 Aug 2009 14:12:22 +0000 (UTC)
commit dfa2cfce0dac5ba1d9f87aea5ff3ab3ed36be6ce
Author: Behdad Esfahbod <behdad behdad org>
Date: Mon Aug 10 20:59:25 2009 -0400
[HB] Add hb_buffer_reverse()
pango/opentype/hb-buffer.c | 32 +++++++++++++++++++++++++++++---
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 c197b90..890a21b 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 57f56bd..4240f6a 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]