[util] Fix leak of an hb_font_t

This commit is contained in:
Behdad Esfahbod 2021-09-14 08:35:19 -04:00
parent da285d511f
commit cd77846bd9
2 changed files with 7 additions and 3 deletions

View File

@ -83,6 +83,7 @@ static struct supported_font_funcs_t {
void
font_options_t::post_parse (GError **error)
{
assert (!font);
font = hb_font_create (face);
if (font_size_x == FONT_SIZE_UPEM)
@ -272,7 +273,8 @@ font_options_t::add_options (option_parser_t *parser)
"font",
"Font-instance options:",
"Options for the font instance",
this);
this,
false /* We add below. */);
const gchar *variations_help = "Comma-separated list of font variations\n"
"\n"

View File

@ -110,11 +110,13 @@ struct option_parser_t
const gchar *name,
const gchar *description,
const gchar *help_description,
Type *closure)
Type *closure,
bool add_parse_hooks = true)
{
GOptionGroup *group = g_option_group_new (name, description, help_description,
static_cast<gpointer>(closure), nullptr);
g_option_group_add_entries (group, entries);
if (add_parse_hooks)
g_option_group_set_parse_hooks (group, nullptr, post_parse<Type>);
g_option_context_add_group (context, group);
}