[HB] Add hb_buffer_reverse()
This commit is contained in:
parent
cbe5a4e08e
commit
fbaf8ffa09
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user