[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.
diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc
index b71aa57..596d38c 100644
--- a/src/hb-buffer.cc
+++ b/src/hb-buffer.cc
@@ -475,18 +475,26 @@
/* Return value valid as long as buffer not modified */
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 value valid as long as buffer not modified */
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)
_hb_buffer_clear_positions (buffer);
+ if (length)
+ *length = buffer->len;
+
return (hb_glyph_position_t *) buffer->pos;
}
diff --git a/src/hb-buffer.h b/src/hb-buffer.h
index 293ec82..3c0a442 100644
--- a/src/hb-buffer.h
+++ b/src/hb-buffer.h
@@ -160,11 +160,13 @@
/* Return value valid as long as buffer not modified */
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 */
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
diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh
index 11bb286..36acf89 100644
--- a/src/hb-ot-layout-gpos-private.hh
+++ b/src/hb-ot-layout-gpos-private.hh
@@ -1493,8 +1493,8 @@
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);
+ unsigned int len;
+ hb_glyph_position_t *pos = hb_buffer_get_glyph_positions (buffer, &len);
hb_direction_t direction = buffer->props.direction;
/* Handle cursive connections:
diff --git a/src/hb-view.c b/src/hb-view.c
index d7e41fd..4e61ee7 100644
--- a/src/hb-view.c
+++ b/src/hb-view.c
@@ -361,8 +361,8 @@
hb_shape (hb_font, hb_face, hb_buffer, features, num_features);
num_glyphs = hb_buffer_get_length (hb_buffer);
- hb_glyph = hb_buffer_get_glyph_infos (hb_buffer);
- hb_position = hb_buffer_get_glyph_positions (hb_buffer);
+ hb_glyph = hb_buffer_get_glyph_infos (hb_buffer, NULL);
+ hb_position = hb_buffer_get_glyph_positions (hb_buffer, NULL);
cairo_glyphs = cairo_glyph_allocate (num_glyphs + 1);
x = 0;
for (i = 0; i < num_glyphs; i++)