From 5a12bf417b927a511ad864abd6305899a1bd135b Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 8 Mar 2025 12:31:07 -0700 Subject: [PATCH] [font-funcs-using] Treat empty string like nullptr --- src/hb-font.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/hb-font.cc b/src/hb-font.cc index dbe915149..561f3c06a 100644 --- a/src/hb-font.cc +++ b/src/hb-font.cc @@ -2330,7 +2330,7 @@ static struct supported_font_funcs_t { * Sets the font-functions structure to use for a font, based on the * specified name. * - * If @name is `NULL`, the first functioning font-functions are used. + * If @name is `NULL` or empty string, the first functioning font-functions are used. * * Return value: `true` if the font-functions was found and set, `false` otherwise * @@ -2340,6 +2340,8 @@ hb_bool_t hb_font_set_funcs_using (hb_font_t *font, const char *name) { + if (name && !*name) name = nullptr; + for (unsigned i = 0; i < ARRAY_LENGTH (supported_font_funcs); i++) if (!name || strcmp (supported_font_funcs[i].name, name) == 0) { @@ -2347,6 +2349,7 @@ hb_font_set_funcs_using (hb_font_t *font, if (name || font->klass != hb_font_funcs_get_empty ()) return true; } + return false; }