summaryrefslogtreecommitdiff
path: root/src/lua/lua_thread.cpp
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-11-23 10:40:04 +1100
committerjacqueline <me@jacqueline.id.au>2023-11-23 10:40:04 +1100
commitb07bfbc6c70fd0bba8dff85fe4149feb9fa9b8d4 (patch)
tree3301506fe015c291afb1f819a9f94bd9047f4a8c /src/lua/lua_thread.cpp
parent9eb5ae6e946651bdbe532b66700bb1ed6944584f (diff)
downloadtangara-fw-b07bfbc6c70fd0bba8dff85fe4149feb9fa9b8d4.tar.gz
Add a second font, flesh out browser screen
Diffstat (limited to 'src/lua/lua_thread.cpp')
-rw-r--r--src/lua/lua_thread.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/lua/lua_thread.cpp b/src/lua/lua_thread.cpp
index e1df3087..4704c3e8 100644
--- a/src/lua/lua_thread.cpp
+++ b/src/lua/lua_thread.cpp
@@ -8,14 +8,20 @@
#include <memory>
+#include "lua.hpp"
+
+#include "font/lv_font_loader.h"
+#include "luavgl.h"
+
#include "esp_heap_caps.h"
#include "esp_log.h"
#include "event_queue.hpp"
-#include "lua.hpp"
-#include "luavgl.h"
#include "service_locator.hpp"
#include "ui_events.hpp"
+LV_FONT_DECLARE(font_fusion_12);
+LV_FONT_DECLARE(font_fusion_10);
+
namespace lua {
[[maybe_unused]] static constexpr char kTag[] = "lua";
@@ -50,6 +56,21 @@ static int lua_panic(lua_State* L) {
return 0;
}
+static auto make_font_cb(const char* name, int size, int weight)
+ -> const lv_font_t* {
+ if (std::string{"fusion"} == name) {
+ if (size == 12) {
+ return &font_fusion_12;
+ }
+ if (size == 10) {
+ return &font_fusion_10;
+ }
+ }
+ return NULL;
+}
+
+static auto delete_font_cb(lv_font_t* font) -> void {}
+
auto LuaThread::Start(system_fsm::ServiceLocator& services, lv_obj_t* lvgl_root)
-> LuaThread* {
auto alloc = std::make_unique<Allocator>();
@@ -66,6 +87,7 @@ auto LuaThread::Start(system_fsm::ServiceLocator& services, lv_obj_t* lvgl_root)
// FIXME: luavgl init should probably be a part of the bridge.
if (lvgl_root) {
luavgl_set_pcall(state, CallProtected);
+ luavgl_set_font_extension(state, make_font_cb, delete_font_cb);
luavgl_set_root(state, lvgl_root);
luaL_requiref(state, "lvgl", luaopen_lvgl, true);
lua_pop(state, 1);