From a1101f09ca896610cdb9361e3f924da74e9d043d Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 25 Jan 2023 13:10:57 -0700 Subject: [PATCH] [test-buffer-serialize] Handle too-small out buffer Need to handle too-small in buffer still. --- src/test-buffer-serialize.cc | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/test-buffer-serialize.cc b/src/test-buffer-serialize.cc index 8a887922b..248c4646f 100644 --- a/src/test-buffer-serialize.cc +++ b/src/test-buffer-serialize.cc @@ -56,10 +56,6 @@ main (int argc, char **argv) hb_font_t *font = hb_font_create (face); hb_face_destroy (face); hb_font_set_scale (font, upem, upem); - //hb_ot_font_set_funcs (font); -#ifdef HAVE_FREETYPE - //hb_ft_font_set_funcs (font); -#endif hb_buffer_t *buf; buf = hb_buffer_create (); @@ -78,11 +74,17 @@ main (int argc, char **argv) if (*p && *p != '\n') ret = false; - hb_buffer_serialize_glyphs (buf, 0, hb_buffer_get_length (buf), - out, sizeof (out), nullptr, - font, HB_BUFFER_SERIALIZE_FORMAT_TEXT, - HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS); - puts (out); + unsigned count = hb_buffer_get_length (buf); + for (unsigned offset = 0; offset < count;) + { + unsigned len; + offset += hb_buffer_serialize_glyphs (buf, offset, count, + out, sizeof (out), &len, + font, HB_BUFFER_SERIALIZE_FORMAT_TEXT, + HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS); + fwrite (out, 1, len, stdout); + } + fputs ("\n", stdout); } hb_buffer_destroy (buf);