[API} hb_buffer_get_glyph_{infos,positions}: Add length out parameter
Return the length, whenever we return an array. Makes it easier on the language bindings.
This commit is contained in:
parent
62879eebd9
commit
70566befc5
|
@ -475,18 +475,26 @@ hb_buffer_get_length (hb_buffer_t *buffer)
|
||||||
|
|
||||||
/* Return value valid as long as buffer not modified */
|
/* Return value valid as long as buffer not modified */
|
||||||
hb_glyph_info_t *
|
hb_glyph_info_t *
|
||||||
hb_buffer_get_glyph_infos (hb_buffer_t *buffer)
|
hb_buffer_get_glyph_infos (hb_buffer_t *buffer,
|
||||||
|
unsigned int *length)
|
||||||
{
|
{
|
||||||
|
if (length)
|
||||||
|
*length = buffer->len;
|
||||||
|
|
||||||
return (hb_glyph_info_t *) buffer->info;
|
return (hb_glyph_info_t *) buffer->info;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return value valid as long as buffer not modified */
|
/* Return value valid as long as buffer not modified */
|
||||||
hb_glyph_position_t *
|
hb_glyph_position_t *
|
||||||
hb_buffer_get_glyph_positions (hb_buffer_t *buffer)
|
hb_buffer_get_glyph_positions (hb_buffer_t *buffer,
|
||||||
|
unsigned int *length)
|
||||||
{
|
{
|
||||||
if (!buffer->have_positions)
|
if (!buffer->have_positions)
|
||||||
_hb_buffer_clear_positions (buffer);
|
_hb_buffer_clear_positions (buffer);
|
||||||
|
|
||||||
|
if (length)
|
||||||
|
*length = buffer->len;
|
||||||
|
|
||||||
return (hb_glyph_position_t *) buffer->pos;
|
return (hb_glyph_position_t *) buffer->pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -160,11 +160,13 @@ hb_buffer_get_length (hb_buffer_t *buffer);
|
||||||
|
|
||||||
/* Return value valid as long as buffer not modified */
|
/* Return value valid as long as buffer not modified */
|
||||||
hb_glyph_info_t *
|
hb_glyph_info_t *
|
||||||
hb_buffer_get_glyph_infos (hb_buffer_t *buffer);
|
hb_buffer_get_glyph_infos (hb_buffer_t *buffer,
|
||||||
|
unsigned int *length);
|
||||||
|
|
||||||
/* Return value valid as long as buffer not modified */
|
/* Return value valid as long as buffer not modified */
|
||||||
hb_glyph_position_t *
|
hb_glyph_position_t *
|
||||||
hb_buffer_get_glyph_positions (hb_buffer_t *buffer);
|
hb_buffer_get_glyph_positions (hb_buffer_t *buffer,
|
||||||
|
unsigned int *length);
|
||||||
|
|
||||||
|
|
||||||
HB_END_DECLS
|
HB_END_DECLS
|
||||||
|
|
|
@ -1493,8 +1493,8 @@ void
|
||||||
GPOS::position_finish (hb_buffer_t *buffer)
|
GPOS::position_finish (hb_buffer_t *buffer)
|
||||||
{
|
{
|
||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
unsigned int len = hb_buffer_get_length (buffer);
|
unsigned int len;
|
||||||
hb_glyph_position_t *pos = hb_buffer_get_glyph_positions (buffer);
|
hb_glyph_position_t *pos = hb_buffer_get_glyph_positions (buffer, &len);
|
||||||
hb_direction_t direction = buffer->props.direction;
|
hb_direction_t direction = buffer->props.direction;
|
||||||
|
|
||||||
/* Handle cursive connections:
|
/* Handle cursive connections:
|
||||||
|
|
|
@ -361,8 +361,8 @@ _hb_cr_text_glyphs (cairo_t *cr,
|
||||||
hb_shape (hb_font, hb_face, hb_buffer, features, num_features);
|
hb_shape (hb_font, hb_face, hb_buffer, features, num_features);
|
||||||
|
|
||||||
num_glyphs = hb_buffer_get_length (hb_buffer);
|
num_glyphs = hb_buffer_get_length (hb_buffer);
|
||||||
hb_glyph = hb_buffer_get_glyph_infos (hb_buffer);
|
hb_glyph = hb_buffer_get_glyph_infos (hb_buffer, NULL);
|
||||||
hb_position = hb_buffer_get_glyph_positions (hb_buffer);
|
hb_position = hb_buffer_get_glyph_positions (hb_buffer, NULL);
|
||||||
cairo_glyphs = cairo_glyph_allocate (num_glyphs + 1);
|
cairo_glyphs = cairo_glyph_allocate (num_glyphs + 1);
|
||||||
x = 0;
|
x = 0;
|
||||||
for (i = 0; i < num_glyphs; i++)
|
for (i = 0; i < num_glyphs; i++)
|
||||||
|
|
|
@ -126,11 +126,9 @@ test_buffer_contents (Fixture *fixture, gconstpointer user_data)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = hb_buffer_get_length (fixture->b);
|
glyphs = hb_buffer_get_glyph_infos (fixture->b, &len);
|
||||||
g_assert_cmpint (len, ==, 5);
|
g_assert_cmpint (len, ==, 5);
|
||||||
|
|
||||||
glyphs = hb_buffer_get_glyph_infos (fixture->b);
|
|
||||||
|
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
unsigned int cluster;
|
unsigned int cluster;
|
||||||
cluster = 1+i;
|
cluster = 1+i;
|
||||||
|
@ -155,8 +153,7 @@ test_buffer_positions (Fixture *fixture, gconstpointer user_data)
|
||||||
hb_glyph_position_t *positions;
|
hb_glyph_position_t *positions;
|
||||||
|
|
||||||
/* Without shaping, positions should all be zero */
|
/* Without shaping, positions should all be zero */
|
||||||
positions = hb_buffer_get_glyph_positions (fixture->b);
|
positions = hb_buffer_get_glyph_positions (fixture->b, &len);
|
||||||
len = hb_buffer_get_length (fixture->b);
|
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
g_assert_cmpint (0, ==, positions[i].x_advance);
|
g_assert_cmpint (0, ==, positions[i].x_advance);
|
||||||
g_assert_cmpint (0, ==, positions[i].y_advance);
|
g_assert_cmpint (0, ==, positions[i].y_advance);
|
||||||
|
|
Loading…
Reference in New Issue