Skip to content

Commit

Permalink
feat: add group method for fontconfig plugin (rxi#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
TorchedSammy authored Nov 27, 2022
1 parent ccd66fd commit e263d07
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion plugins/fontconfig.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit e263d07

Please sign in to comment.