aboutsummaryrefslogtreecommitdiff
path: root/src/sysbin
diff options
context:
space:
mode:
Diffstat (limited to 'src/sysbin')
-rw-r--r--src/sysbin/lx/lua_cmsgpack.c1
-rw-r--r--src/sysbin/lx/lxdrawlib.c29
-rw-r--r--src/sysbin/terminal/main.c4
3 files changed, 27 insertions, 7 deletions
diff --git a/src/sysbin/lx/lua_cmsgpack.c b/src/sysbin/lx/lua_cmsgpack.c
index 57c378e..8eb15fc 100644
--- a/src/sysbin/lx/lua_cmsgpack.c
+++ b/src/sysbin/lx/lua_cmsgpack.c
@@ -19,6 +19,7 @@
#endif
/* Check if float or double can be an integer without loss of precision */
+#define isinf(x) (false)
#define IS_INT_TYPE_EQUIVALENT(x, T) (!isinf(x) && (T)(x) == (x))
#define IS_INT64_EQUIVALENT(x) IS_INT_TYPE_EQUIVALENT(x, int64_t)
diff --git a/src/sysbin/lx/lxdrawlib.c b/src/sysbin/lx/lxdrawlib.c
index 68da1d6..22c6a3b 100644
--- a/src/sysbin/lx/lxdrawlib.c
+++ b/src/sysbin/lx/lxdrawlib.c
@@ -41,9 +41,26 @@ typedef struct {
// ====================================================================
// FONTS
-static int draw_loadfont(lua_State *L) {
+static int draw_load_bitmap_font(lua_State *L) {
const char* name = luaL_checkstring(L, 1);
- font_t *f = g_load_font(name);
+ font_t *f = g_load_ascii_bitmap_font(name);
+ if (f == NULL) {
+ lua_pushnil(L);
+ return 1;
+ }
+
+ drawlib_font *ff = (drawlib_font*)lua_newuserdata(L, sizeof(drawlib_font));
+ luaL_getmetatable(L, FONT);
+ lua_setmetatable(L, -2);
+
+ ff->font = f;
+
+ return 1;
+}
+
+static int draw_load_ttf_font(lua_State *L) {
+ const char* name = luaL_checkstring(L, 1);
+ font_t *f = g_load_ttf_font(name);
if (f == NULL) {
lua_pushnil(L);
return 1;
@@ -384,10 +401,11 @@ static int surface_write(lua_State *L) {
int y = luaL_checkinteger(L, 3);
const char *text = luaL_checkstring(L, 4);
drawlib_font *f = (drawlib_font*)luaL_checkudata(L, 5, FONT);
- color_t c = (color_t)lx_checklightudata(L, 6);
+ int size = luaL_checkinteger(L, 6);
+ color_t c = (color_t)lx_checklightudata(L, 7);
// TODO: relative to subregion!
- g_write(s->fb, x, y, text, f->font, c);
+ g_write(s->fb, x, y, text, f->font, size, c);
return 0;
}
@@ -397,7 +415,8 @@ static const luaL_Reg drawlib[] = {
{"surface_from_fd",draw_surface_from_fd},
{"new_surface", draw_new_surface},
{"load_image", draw_load_image},
- {"load_font", draw_loadfont},
+ {"load_bitmap_font",draw_load_bitmap_font},
+ {"load_ttf_font",draw_load_ttf_font},
{NULL, NULL}
};
diff --git a/src/sysbin/terminal/main.c b/src/sysbin/terminal/main.c
index 13f39ca..4805f9d 100644
--- a/src/sysbin/terminal/main.c
+++ b/src/sysbin/terminal/main.c
@@ -101,7 +101,7 @@ int main(int argc, char **argv) {
term.kb = init_keyboard();
ASSERT(term.kb != 0);
- term.font = g_load_font("sys:/fonts/default.bf");
+ term.font = g_load_ascii_bitmap_font("sys:/fonts/default.bf");
ASSERT(term.font != 0);
term.cw = g_text_width(term.font, "#");
term.ch = g_text_height(term.font, "#");
@@ -138,7 +138,7 @@ void term_draw_c(term_t *t, int l, int c) {
if (t->fb) {
g_fillrect(t->fb, c * t->cw, l * t->ch, t->cw, t->ch, bg);
- g_write(t->fb, c * t->cw, l * t->ch, ss, t->font, t->fg);
+ g_write(t->fb, c * t->cw, l * t->ch, ss, t->font, 16, t->fg);
}
}