aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjgmdev <jgmdev@gmail.com>2022-08-11 10:28:33 -0400
committerjgmdev <jgmdev@gmail.com>2022-08-11 10:28:40 -0400
commit090c14a3b4b1d4ae3129206b3ca93f73642916ba (patch)
treeae558f466151e36c3aa11cb6c96277d2df2303fa
parenta59546d90ff134e4dcc37e51776b86333e626c18 (diff)
downloadlite-xl-plugins-090c14a3b4b1d4ae3129206b3ca93f73642916ba.tar.gz
lite-xl-plugins-090c14a3b4b1d4ae3129206b3ca93f73642916ba.zip
settings: handle font loading error
-rw-r--r--plugins/settings.lua26
1 files 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