aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjgmdev <jgmdev@gmail.com>2022-08-11 12:04:31 -0400
committerjgmdev <jgmdev@gmail.com>2022-08-11 12:04:31 -0400
commit0ef2e01e13ccf0307dbc60cff9a5296736525acb (patch)
tree7147dd580ad8622474aba4a043629961a65ea0f7
parent090c14a3b4b1d4ae3129206b3ca93f73642916ba (diff)
downloadlite-xl-plugins-0ef2e01e13ccf0307dbc60cff9a5296736525acb.tar.gz
lite-xl-plugins-0ef2e01e13ccf0307dbc60cff9a5296736525acb.zip
settings: revert to default fonts on load error
-rw-r--r--plugins/settings.lua11
1 files changed, 10 insertions, 1 deletions
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<string, renderer.font>
+---@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 .. ":")