|
|
@@ -13,7 +13,9 @@
|
|
|
#include "luat_lvgl_fonts.h"
|
|
|
#include "luat_spi.h"
|
|
|
|
|
|
-extern luat_spi_device_t* gt_spi_dev;
|
|
|
+#ifdef LUAT_USE_GTFONT
|
|
|
+ extern luat_spi_device_t* gt_spi_dev;
|
|
|
+#endif
|
|
|
|
|
|
/*
|
|
|
获取内置字体
|
|
|
@@ -81,23 +83,23 @@ local font = lvgl.font_load("/font_simsun_32.bin")
|
|
|
int luat_lv_font_load(lua_State *L) {
|
|
|
lv_font_t *font = NULL;
|
|
|
if (lua_isuserdata(L, 1)) {
|
|
|
- luat_spi_device_t *spi = lua_touserdata(L, 1);
|
|
|
- uint8_t size = luaL_optinteger(L, 2, 16);
|
|
|
- uint8_t bpp = luaL_optinteger(L, 3, 4);
|
|
|
- uint16_t thickness = luaL_optinteger(L, 4, size * bpp);
|
|
|
- uint8_t cache_size = luaL_optinteger(L, 5, 0);
|
|
|
- uint8_t sty_zh = luaL_optinteger(L, 6, 1);
|
|
|
- uint8_t sty_en = luaL_optinteger(L, 7, 3);
|
|
|
-
|
|
|
- if (!(bpp >= 1 && bpp <= 4 && bpp != 3)) {
|
|
|
- return 0;
|
|
|
- }
|
|
|
-
|
|
|
- if (gt_spi_dev == NULL) {
|
|
|
- gt_spi_dev = lua_touserdata(L, 1);
|
|
|
- }
|
|
|
+ #ifdef LUAT_USE_GTFONT
|
|
|
+ luat_spi_device_t *spi = lua_touserdata(L, 1);
|
|
|
+ uint8_t size = luaL_optinteger(L, 2, 16);
|
|
|
+ uint8_t bpp = luaL_optinteger(L, 3, 4);
|
|
|
+ uint16_t thickness = luaL_optinteger(L, 4, size * bpp);
|
|
|
+ uint8_t cache_size = luaL_optinteger(L, 5, 0);
|
|
|
+ uint8_t sty_zh = luaL_optinteger(L, 6, 1);
|
|
|
+ uint8_t sty_en = luaL_optinteger(L, 7, 3);
|
|
|
|
|
|
- font = lv_font_new_gt(sty_zh, sty_en, size, bpp, thickness, cache_size);
|
|
|
+ if (!(bpp >= 1 && bpp <= 4 && bpp != 3)) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ if (gt_spi_dev == NULL) {
|
|
|
+ gt_spi_dev = lua_touserdata(L, 1);
|
|
|
+ }
|
|
|
+ font = lv_font_new_gt(sty_zh, sty_en, size, bpp, thickness, cache_size);
|
|
|
+ #endif
|
|
|
} else {
|
|
|
const char* fontname = luaL_checkstring(L, 1);
|
|
|
font = lv_font_load(fontname);
|