From 0ef2e01e13ccf0307dbc60cff9a5296736525acb Mon Sep 17 00:00:00 2001 From: jgmdev Date: Thu, 11 Aug 2022 12:04:31 -0400 Subject: settings: revert to default fonts on load error --- plugins/settings.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'plugins/settings.lua') diff --git a/plugins/settings.lua b/plugins/settings.lua index 0f077bc..89521ab 100644 --- a/plugins/settings.lua +++ b/plugins/settings.lua @@ -69,6 +69,7 @@ settings.type = { ---@field public step number ---@field public values table ---@field public fonts_list table +---@field public font_error boolean ---@field public get_value nil | fun(value:any):any ---@field public set_value nil | fun(value:any):any ---@field public icon string @@ -95,6 +96,8 @@ settings.option = { values = {}, ---Optionally used for FONT to store the generated font group. fonts_list = {}, + ---Flag set to true when loading user defined fonts fail + font_error = false, ---Optional function that is used to manipulate the current value on retrieval. get_value = nil, ---Optional function that is used to manipulate the saved value on save. @@ -852,6 +855,7 @@ local function merge_font_settings(option, path, saved_value) if font_loaded then table.insert(fonts, font_data) else + option.font_error = true core.error("Settings: could not load %s\n'%s - %s'", path, font.name, font.path) break end @@ -1098,7 +1102,12 @@ local function add_control(pane, option, plugin_name) elseif option.type == settings.type.FONT then --get fonts without conversion to renderer.font if type(path) ~= "nil" then - option_value = get_config_value(settings.config, path, option.default) + if not option.font_error then + option_value = get_config_value(settings.config, path, option.default) + else + --fallback to default fonts if error loading user defined ones + option_value = option.default + end end ---@type widget.label Label(pane, option.label .. ":") -- cgit v1.2.3