From 090c14a3b4b1d4ae3129206b3ca93f73642916ba Mon Sep 17 00:00:00 2001 From: jgmdev Date: Thu, 11 Aug 2022 10:28:33 -0400 Subject: settings: handle font loading error --- plugins/settings.lua | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/plugins/settings.lua b/plugins/settings.lua index a489430..0f077bc 100644 --- a/plugins/settings.lua +++ b/plugins/settings.lua @@ -841,16 +841,28 @@ local function merge_font_settings(option, path, saved_value) font_options.hinting = font_options.hinting or "slight" local fonts = {} + local font_loaded = true for _, font in ipairs(saved_value.fonts) do - table.insert(fonts, renderer.font.load( - font.path, font_options.size * SCALE, font_options - )) + local font_data = nil + font_loaded = core.try(function() + font_data = renderer.font.load( + font.path, font_options.size * SCALE, font_options + ) + end) + if font_loaded then + table.insert(fonts, font_data) + else + core.error("Settings: could not load %s\n'%s - %s'", path, font.name, font.path) + break + end end - if option.fonts_list then - set_config_value(option.fonts_list, option.path, renderer.font.group(fonts)) - else - set_config_value(config, path, renderer.font.group(fonts)) + if font_loaded then + if option.fonts_list then + set_config_value(option.fonts_list, option.path, renderer.font.group(fonts)) + else + set_config_value(config, path, renderer.font.group(fonts)) + end end end -- cgit v1.2.3