diff options
author | sammy <38820196+TorchedSammy@users.noreply.github.com> | 2022-11-27 11:29:18 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-27 11:29:18 -0400 |
commit | e263d07cba069726fe3ee903b982b5434d1350c2 (patch) | |
tree | f7ff4264b992c409225a1095bb785026f185682f /plugins | |
parent | ccd66fd921e0e837b314249341eece7b4d5a135d (diff) | |
download | lite-xl-plugins-e263d07cba069726fe3ee903b982b5434d1350c2.tar.gz lite-xl-plugins-e263d07cba069726fe3ee903b982b5434d1350c2.zip |
feat: add group method for fontconfig plugin (#157)
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/fontconfig.lua | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/plugins/fontconfig.lua b/plugins/fontconfig.lua index 8b713b5..03a2f95 100644 --- a/plugins/fontconfig.lua +++ b/plugins/fontconfig.lua @@ -75,6 +75,24 @@ function M.load_blocking(font_name, font_size, font_opt) return result end +function M.load_group_blocking(group, font_size, font_opt) + local fonts = {} + for i in ipairs(group) do + local co = coroutine.create(function() + return M.load(group[i], font_size, font_opt) + end) + local result + while coroutine.status(co) ~= "dead" do + local ok, err = coroutine.resume(co) + if not ok then error(err) end + result = err + end + table.insert(fonts, result) + end + + return renderer.font.group(fonts) +end + function M.use(spec) core.add_thread(function() for key, value in pairs(spec) do @@ -87,7 +105,13 @@ end -- I'll leave this here function M.use_blocking(spec) for key, value in pairs(spec) do - style[key] = M.load_blocking(value.name, value.size, value) + local font + if value.group then + font = M.load_group_blocking(value.group, value.size, value) + else + font = M.load_blocking(value.name, value.size, value) + end + style[key] = font end end |