Fork of Tangara with customizations
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
tangara-fw/lua/font.lua

40 lines
856 B

-- SPDX-FileCopyrightText: 2023 jacqueline <me@jacqueline.id.au>
--
-- SPDX-License-Identifier: GPL-3.0-only
local lvgl = require("lvgl")
local fonts = {}
local fonts_priv = {
has_invoked_cb = false,
cb = nil,
}
function fonts_priv.has_loaded_all()
return fonts.fusion_12 and fonts.fusion_10
end
function fonts_priv.invoke_cb()
if fonts_priv.has_invoked_cb or not fonts_priv.cb then return end
if not fonts_priv.has_loaded_all() then return end
fonts_priv.has_invoked_cb = true
fonts_priv.cb()
end
lvgl.Font("//lua/fonts/fusion12", function(font)
fonts.fusion_12 = font
fonts_priv.invoke_cb()
end)
lvgl.Font("//lua/fonts/fusion10", function(font)
fonts.fusion_10 = font
fonts_priv.invoke_cb()
end)
function fonts.on_loaded(cb)
fonts_priv.cb = cb
fonts_priv.has_invoked_cb = false
fonts_priv.invoke_cb()
end
return fonts