From f798cf225ec4dab7fa4683224e26f3df08c59189 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 23 Jan 2023 20:57:30 -0700 Subject: [PATCH] [util] Don't require final ']' in --glyphs --- util/shape-options.hh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/util/shape-options.hh b/util/shape-options.hh index 07dc4c138..87862cd7a 100644 --- a/util/shape-options.hh +++ b/util/shape-options.hh @@ -75,11 +75,26 @@ struct shape_options_t * as guess_segment_properties doesn't like glyphs in the buffer. */ setup_buffer (buffer); + char *glyphs = (char *) text; + int glyphs_len = text_len; + if (glyphs_len < 0) + glyphs_len = strlen (glyphs); + + if (glyphs_len && glyphs[glyphs_len - 1] != ']') + { + glyphs = g_strdup_printf ("%*s]", glyphs_len, glyphs); + glyphs_len = -1; + } + hb_buffer_deserialize_glyphs (buffer, - text, text_len, + glyphs, glyphs_len, nullptr, font, HB_BUFFER_SERIALIZE_FORMAT_TEXT); + + if (glyphs != text) + g_free (glyphs); + return; }