2 * Copyright © 2012,2013 Google, Inc.
4 * This is part of HarfBuzz, a text shaping library.
6 * Permission is hereby granted, without written agreement and without
7 * license or royalty fees, to use, copy, modify, and distribute this
8 * software and its documentation for any purpose, provided that the
9 * above copyright notice and the following two paragraphs appear in
10 * all copies of this software.
12 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
13 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
14 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
15 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
18 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
19 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
21 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
22 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
24 * Google Author(s): Behdad Esfahbod
29 #ifndef HB_NO_BUFFER_SERIALIZE
31 #include "hb-buffer.hh"
34 static const char *_hb_buffer_serialize_formats[] = {
41 * hb_buffer_serialize_list_formats:
43 * Returns a list of supported buffer serialization formats.
45 * Return value: (transfer none):
46 * A string array of buffer serialization formats. Should not be freed.
51 hb_buffer_serialize_list_formats ()
53 return _hb_buffer_serialize_formats;
57 * hb_buffer_serialize_format_from_string:
58 * @str: (array length=len) (element-type uint8_t): a string to parse
59 * @len: length of @str, or -1 if string is `NULL` terminated
61 * Parses a string into an #hb_buffer_serialize_format_t. Does not check if
62 * @str is a valid buffer serialization format, use
63 * hb_buffer_serialize_list_formats() to get the list of supported formats.
66 * The parsed #hb_buffer_serialize_format_t.
70 hb_buffer_serialize_format_t
71 hb_buffer_serialize_format_from_string (const char *str, int len)
74 return (hb_buffer_serialize_format_t) (hb_tag_from_string (str, len) & ~0x20202020u);
78 * hb_buffer_serialize_format_to_string:
79 * @format: an #hb_buffer_serialize_format_t to convert.
81 * Converts @format to the string corresponding it, or `NULL` if it is not a valid
82 * #hb_buffer_serialize_format_t.
84 * Return value: (transfer none):
85 * A `NULL` terminated string corresponding to @format. Should not be freed.
90 hb_buffer_serialize_format_to_string (hb_buffer_serialize_format_t format)
92 switch ((unsigned) format)
94 case HB_BUFFER_SERIALIZE_FORMAT_TEXT: return _hb_buffer_serialize_formats[0];
95 case HB_BUFFER_SERIALIZE_FORMAT_JSON: return _hb_buffer_serialize_formats[1];
97 case HB_BUFFER_SERIALIZE_FORMAT_INVALID: return nullptr;
102 _hb_buffer_serialize_glyphs_json (hb_buffer_t *buffer,
106 unsigned int buf_size,
107 unsigned int *buf_consumed,
109 hb_buffer_serialize_flags_t flags)
111 hb_glyph_info_t *info = hb_buffer_get_glyph_infos (buffer, nullptr);
112 hb_glyph_position_t *pos = (flags & HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS) ?
113 nullptr : hb_buffer_get_glyph_positions (buffer, nullptr);
116 hb_position_t x = 0, y = 0;
117 for (unsigned int i = start; i < end; i++)
122 /* In the following code, we know b is large enough that no overflow can happen. */
124 #define APPEND(s) HB_STMT_START { strcpy (p, s); p += strlen (s); } HB_STMT_END
134 if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES))
137 hb_font_glyph_to_string (font, info[i].codepoint, g, sizeof (g));
139 for (char *q = g; *q; q++)
141 if (unlikely (*q == '"' || *q == '\\'))
148 p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "%u", info[i].codepoint));
150 if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS)) {
151 p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"cl\":%u", info[i].cluster));
154 if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS))
156 p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"dx\":%d,\"dy\":%d",
157 x+pos[i].x_offset, y+pos[i].y_offset));
158 if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES))
159 p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"ax\":%d,\"ay\":%d",
160 pos[i].x_advance, pos[i].y_advance));
163 if (flags & HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS)
165 if (info[i].mask & HB_GLYPH_FLAG_DEFINED)
166 p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"fl\":%u", info[i].mask & HB_GLYPH_FLAG_DEFINED));
169 if (flags & HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS)
171 hb_glyph_extents_t extents;
172 hb_font_get_glyph_extents(font, info[i].codepoint, &extents);
173 p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"xb\":%d,\"yb\":%d",
174 extents.x_bearing, extents.y_bearing));
175 p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"w\":%d,\"h\":%d",
176 extents.width, extents.height));
183 unsigned int l = p - b;
186 hb_memcpy (buf, b, l);
194 if (pos && (flags & HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES))
196 x += pos[i].x_advance;
197 y += pos[i].y_advance;
205 _hb_buffer_serialize_unicode_json (hb_buffer_t *buffer,
209 unsigned int buf_size,
210 unsigned int *buf_consumed,
211 hb_buffer_serialize_flags_t flags)
213 hb_glyph_info_t *info = hb_buffer_get_glyph_infos (buffer, nullptr);
216 for (unsigned int i = start; i < end; i++)
230 p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "%u", info[i].codepoint));
232 if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS)) {
233 p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",\"cl\":%u", info[i].cluster));
241 unsigned int l = p - b;
244 hb_memcpy (buf, b, l);
258 _hb_buffer_serialize_glyphs_text (hb_buffer_t *buffer,
262 unsigned int buf_size,
263 unsigned int *buf_consumed,
265 hb_buffer_serialize_flags_t flags)
267 hb_glyph_info_t *info = hb_buffer_get_glyph_infos (buffer, nullptr);
268 hb_glyph_position_t *pos = (flags & HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS) ?
269 nullptr : hb_buffer_get_glyph_positions (buffer, nullptr);
272 hb_position_t x = 0, y = 0;
273 for (unsigned int i = start; i < end; i++)
278 /* In the following code, we know b is large enough that no overflow can happen. */
285 if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES))
287 /* TODO Escape delimiters we use. */
288 hb_font_glyph_to_string (font, info[i].codepoint, p, 128);
292 p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "%u", info[i].codepoint));
294 if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS)) {
295 p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "=%u", info[i].cluster));
298 if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS))
300 if (x+pos[i].x_offset || y+pos[i].y_offset)
301 p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "@%d,%d", x+pos[i].x_offset, y+pos[i].y_offset));
303 if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES))
306 p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "%d", pos[i].x_advance));
307 if (pos[i].y_advance)
308 p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), ",%d", pos[i].y_advance));
312 if (flags & HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS)
314 if (info[i].mask & HB_GLYPH_FLAG_DEFINED)
315 p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "#%X", info[i].mask &HB_GLYPH_FLAG_DEFINED));
318 if (flags & HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS)
320 hb_glyph_extents_t extents;
321 hb_font_get_glyph_extents(font, info[i].codepoint, &extents);
322 p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "<%d,%d,%d,%d>", extents.x_bearing, extents.y_bearing, extents.width, extents.height));
329 unsigned int l = p - b;
332 hb_memcpy (buf, b, l);
340 if (pos && (flags & HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES))
342 x += pos[i].x_advance;
343 y += pos[i].y_advance;
352 _hb_buffer_serialize_unicode_text (hb_buffer_t *buffer,
356 unsigned int buf_size,
357 unsigned int *buf_consumed,
358 hb_buffer_serialize_flags_t flags)
360 hb_glyph_info_t *info = hb_buffer_get_glyph_infos (buffer, nullptr);
362 for (unsigned int i = start; i < end; i++)
372 p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "U+%04X", info[i].codepoint));
374 if (!(flags & HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS)) {
375 p += hb_max (0, snprintf (p, ARRAY_LENGTH (b) - (p - b), "=%u", info[i].cluster));
381 unsigned int l = p - b;
384 hb_memcpy (buf, b, l);
396 * hb_buffer_serialize_glyphs:
397 * @buffer: an #hb_buffer_t buffer.
398 * @start: the first item in @buffer to serialize.
399 * @end: the last item in @buffer to serialize.
400 * @buf: (out) (array length=buf_size) (element-type uint8_t): output string to
401 * write serialized buffer into.
402 * @buf_size: the size of @buf.
403 * @buf_consumed: (out) (optional): if not `NULL`, will be set to the number of bytes written into @buf.
404 * @font: (nullable): the #hb_font_t used to shape this buffer, needed to
405 * read glyph names and extents. If `NULL`, an empty font will be used.
406 * @format: the #hb_buffer_serialize_format_t to use for formatting the output.
407 * @flags: the #hb_buffer_serialize_flags_t that control what glyph properties
410 * Serializes @buffer into a textual representation of its glyph content,
411 * useful for showing the contents of the buffer, for example during debugging.
412 * There are currently two supported serialization formats:
415 * A human-readable, plain text format.
416 * The serialized glyphs will look something like:
419 * [uni0651=0@518,0+0|uni0628=0+1897]
422 * - The serialized glyphs are delimited with `[` and `]`.
423 * - Glyphs are separated with `|`
424 * - Each glyph starts with glyph name, or glyph index if
425 * #HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES flag is set. Then,
426 * - If #HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS is not set, `=` then #hb_glyph_info_t.cluster.
427 * - If #HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS is not set, the #hb_glyph_position_t in the format:
428 * - If both #hb_glyph_position_t.x_offset and #hb_glyph_position_t.y_offset are not 0, `@x_offset,y_offset`. Then,
429 * - `+x_advance`, then `,y_advance` if #hb_glyph_position_t.y_advance is not 0. Then,
430 * - If #HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS is set, the #hb_glyph_extents_t in the format `<x_bearing,y_bearing,width,height>`
433 * A machine-readable, structured format.
434 * The serialized glyphs will look something like:
437 * [{"g":"uni0651","cl":0,"dx":518,"dy":0,"ax":0,"ay":0},
438 * {"g":"uni0628","cl":0,"dx":0,"dy":0,"ax":1897,"ay":0}]
441 * Each glyph is a JSON object, with the following properties:
442 * - `g`: the glyph name or glyph index if
443 * #HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES flag is set.
444 * - `cl`: #hb_glyph_info_t.cluster if
445 * #HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS is not set.
446 * - `dx`,`dy`,`ax`,`ay`: #hb_glyph_position_t.x_offset, #hb_glyph_position_t.y_offset,
447 * #hb_glyph_position_t.x_advance and #hb_glyph_position_t.y_advance
448 * respectively, if #HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS is not set.
449 * - `xb`,`yb`,`w`,`h`: #hb_glyph_extents_t.x_bearing, #hb_glyph_extents_t.y_bearing,
450 * #hb_glyph_extents_t.width and #hb_glyph_extents_t.height respectively if
451 * #HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS is set.
454 * The number of serialized items.
459 hb_buffer_serialize_glyphs (hb_buffer_t *buffer,
463 unsigned int buf_size,
464 unsigned int *buf_consumed,
466 hb_buffer_serialize_format_t format,
467 hb_buffer_serialize_flags_t flags)
469 end = hb_clamp (end, start, buffer->len);
470 start = hb_min (start, end);
472 unsigned int sconsumed;
474 buf_consumed = &sconsumed;
479 buffer->assert_glyphs ();
481 if (!buffer->have_positions)
482 flags |= HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS;
484 if (unlikely (start == end))
488 font = hb_font_get_empty ();
492 case HB_BUFFER_SERIALIZE_FORMAT_TEXT:
493 return _hb_buffer_serialize_glyphs_text (buffer, start, end,
494 buf, buf_size, buf_consumed,
497 case HB_BUFFER_SERIALIZE_FORMAT_JSON:
498 return _hb_buffer_serialize_glyphs_json (buffer, start, end,
499 buf, buf_size, buf_consumed,
503 case HB_BUFFER_SERIALIZE_FORMAT_INVALID:
510 * hb_buffer_serialize_unicode:
511 * @buffer: an #hb_buffer_t buffer.
512 * @start: the first item in @buffer to serialize.
513 * @end: the last item in @buffer to serialize.
514 * @buf: (out) (array length=buf_size) (element-type uint8_t): output string to
515 * write serialized buffer into.
516 * @buf_size: the size of @buf.
517 * @buf_consumed: (out) (optional): if not `NULL`, will be set to the number of bytes written into @buf.
518 * @format: the #hb_buffer_serialize_format_t to use for formatting the output.
519 * @flags: the #hb_buffer_serialize_flags_t that control what glyph properties
522 * Serializes @buffer into a textual representation of its content,
523 * when the buffer contains Unicode codepoints (i.e., before shaping). This is
524 * useful for showing the contents of the buffer, for example during debugging.
525 * There are currently two supported serialization formats:
528 * A human-readable, plain text format.
529 * The serialized codepoints will look something like:
532 * <U+0651=0|U+0628=1>
535 * - Glyphs are separated with `|`
536 * - Unicode codepoints are expressed as zero-padded four (or more)
537 * digit hexadecimal numbers preceded by `U+`
538 * - If #HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS is not set, the cluster
539 * will be indicated with a `=` then #hb_glyph_info_t.cluster.
542 * A machine-readable, structured format.
543 * The serialized codepoints will be a list of objects with the following
545 * - `u`: the Unicode codepoint as a decimal integer
546 * - `cl`: #hb_glyph_info_t.cluster if
547 * #HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS is not set.
552 * [{u:1617,cl:0},{u:1576,cl:1}]
556 * The number of serialized items.
561 hb_buffer_serialize_unicode (hb_buffer_t *buffer,
565 unsigned int buf_size,
566 unsigned int *buf_consumed,
567 hb_buffer_serialize_format_t format,
568 hb_buffer_serialize_flags_t flags)
570 end = hb_clamp (end, start, buffer->len);
571 start = hb_min (start, end);
573 unsigned int sconsumed;
575 buf_consumed = &sconsumed;
580 buffer->assert_unicode ();
582 if (unlikely (start == end))
587 case HB_BUFFER_SERIALIZE_FORMAT_TEXT:
588 return _hb_buffer_serialize_unicode_text (buffer, start, end,
589 buf, buf_size, buf_consumed, flags);
591 case HB_BUFFER_SERIALIZE_FORMAT_JSON:
592 return _hb_buffer_serialize_unicode_json (buffer, start, end,
593 buf, buf_size, buf_consumed, flags);
596 case HB_BUFFER_SERIALIZE_FORMAT_INVALID:
603 _hb_buffer_serialize_invalid (hb_buffer_t *buffer,
607 unsigned int buf_size,
608 unsigned int *buf_consumed,
609 hb_buffer_serialize_format_t format,
610 hb_buffer_serialize_flags_t flags)
612 assert (!buffer->len);
614 unsigned int sconsumed;
616 buf_consumed = &sconsumed;
619 if (format == HB_BUFFER_SERIALIZE_FORMAT_JSON) {
623 } else if (format == HB_BUFFER_SERIALIZE_FORMAT_TEXT) {
633 * hb_buffer_serialize:
634 * @buffer: an #hb_buffer_t buffer.
635 * @start: the first item in @buffer to serialize.
636 * @end: the last item in @buffer to serialize.
637 * @buf: (out) (array length=buf_size) (element-type uint8_t): output string to
638 * write serialized buffer into.
639 * @buf_size: the size of @buf.
640 * @buf_consumed: (out) (optional): if not `NULL`, will be set to the number of bytes written into @buf.
641 * @font: (nullable): the #hb_font_t used to shape this buffer, needed to
642 * read glyph names and extents. If `NULL`, an empty font will be used.
643 * @format: the #hb_buffer_serialize_format_t to use for formatting the output.
644 * @flags: the #hb_buffer_serialize_flags_t that control what glyph properties
647 * Serializes @buffer into a textual representation of its content, whether
648 * Unicode codepoints or glyph identifiers and positioning information. This is
649 * useful for showing the contents of the buffer, for example during debugging.
650 * See the documentation of hb_buffer_serialize_unicode() and
651 * hb_buffer_serialize_glyphs() for a description of the output format.
654 * The number of serialized items.
659 hb_buffer_serialize (hb_buffer_t *buffer,
663 unsigned int buf_size,
664 unsigned int *buf_consumed,
666 hb_buffer_serialize_format_t format,
667 hb_buffer_serialize_flags_t flags)
669 switch (buffer->content_type)
672 case HB_BUFFER_CONTENT_TYPE_GLYPHS:
673 return hb_buffer_serialize_glyphs (buffer, start, end, buf, buf_size,
674 buf_consumed, font, format, flags);
676 case HB_BUFFER_CONTENT_TYPE_UNICODE:
677 return hb_buffer_serialize_unicode (buffer, start, end, buf, buf_size,
678 buf_consumed, format, flags);
680 case HB_BUFFER_CONTENT_TYPE_INVALID:
682 return _hb_buffer_serialize_invalid (buffer, start, end, buf, buf_size,
683 buf_consumed, format, flags);
688 parse_int (const char *pp, const char *end, int32_t *pv)
692 if (unlikely (!hb_parse_int (&p, end, &v, true/* whole buffer */)))
700 parse_uint (const char *pp, const char *end, uint32_t *pv)
704 if (unlikely (!hb_parse_uint (&p, end, &v, true/* whole buffer */)))
712 parse_hex (const char *pp, const char *end, uint32_t *pv)
716 if (unlikely (!hb_parse_uint (&p, end, &v, true/* whole buffer */, 16)))
723 #include "hb-buffer-deserialize-json.hh"
724 #include "hb-buffer-deserialize-text-glyphs.hh"
725 #include "hb-buffer-deserialize-text-unicode.hh"
728 * hb_buffer_deserialize_glyphs:
729 * @buffer: an #hb_buffer_t buffer.
730 * @buf: (array length=buf_len): string to deserialize
731 * @buf_len: the size of @buf, or -1 if it is `NULL`-terminated
732 * @end_ptr: (out) (optional): output pointer to the character after last
734 * @font: (nullable): font for getting glyph IDs
735 * @format: the #hb_buffer_serialize_format_t of the input @buf
737 * Deserializes glyphs @buffer from textual representation in the format
738 * produced by hb_buffer_serialize_glyphs().
740 * Return value: `true` if parse was successful, `false` if an error
746 hb_buffer_deserialize_glyphs (hb_buffer_t *buffer,
748 int buf_len, /* -1 means nul-terminated */
749 const char **end_ptr, /* May be NULL */
750 hb_font_t *font, /* May be NULL */
751 hb_buffer_serialize_format_t format)
758 buffer->assert_glyphs ();
760 if (unlikely (hb_object_is_immutable (buffer)))
768 buf_len = strlen (buf);
776 hb_buffer_set_content_type (buffer, HB_BUFFER_CONTENT_TYPE_GLYPHS);
779 font = hb_font_get_empty ();
783 case HB_BUFFER_SERIALIZE_FORMAT_TEXT:
784 return _hb_buffer_deserialize_text_glyphs (buffer,
785 buf, buf_len, end_ptr,
788 case HB_BUFFER_SERIALIZE_FORMAT_JSON:
789 return _hb_buffer_deserialize_json (buffer,
790 buf, buf_len, end_ptr,
794 case HB_BUFFER_SERIALIZE_FORMAT_INVALID:
802 * hb_buffer_deserialize_unicode:
803 * @buffer: an #hb_buffer_t buffer.
804 * @buf: (array length=buf_len): string to deserialize
805 * @buf_len: the size of @buf, or -1 if it is `NULL`-terminated
806 * @end_ptr: (out) (optional): output pointer to the character after last
808 * @format: the #hb_buffer_serialize_format_t of the input @buf
810 * Deserializes Unicode @buffer from textual representation in the format
811 * produced by hb_buffer_serialize_unicode().
813 * Return value: `true` if parse was successful, `false` if an error
819 hb_buffer_deserialize_unicode (hb_buffer_t *buffer,
821 int buf_len, /* -1 means nul-terminated */
822 const char **end_ptr, /* May be NULL */
823 hb_buffer_serialize_format_t format)
830 buffer->assert_unicode ();
832 if (unlikely (hb_object_is_immutable (buffer)))
840 buf_len = strlen (buf);
848 hb_buffer_set_content_type (buffer, HB_BUFFER_CONTENT_TYPE_UNICODE);
850 hb_font_t* font = hb_font_get_empty ();
854 case HB_BUFFER_SERIALIZE_FORMAT_TEXT:
855 return _hb_buffer_deserialize_text_unicode (buffer,
856 buf, buf_len, end_ptr,
859 case HB_BUFFER_SERIALIZE_FORMAT_JSON:
860 return _hb_buffer_deserialize_json (buffer,
861 buf, buf_len, end_ptr,
865 case HB_BUFFER_SERIALIZE_FORMAT_INVALID: