Move to k3 SDF fonts

This commit is contained in:
mid 2025-12-02 00:04:05 +02:00
parent 5f6dc66a0f
commit 0453585751
2 changed files with 6 additions and 15 deletions

View File

@ -333,21 +333,11 @@ static int texloader(void *ud, struct ResManRes *res) {
}
static int fontloader(void *ud, struct ResManRes *res) {
FILE *fntf = fopen(res->name, "rb");
fseek(fntf, 0, SEEK_END);
size_t fntfsz = ftell(fntf);
fseek(fntf, 0, SEEK_SET);
char *fntbuf = malloc(fntfsz);
fread(fntbuf, 1, fntfsz, fntf);
char namebuf[256];
snprintf(namebuf, sizeof(namebuf), "assets/%s", res->name);
struct k3Font *fnt = k3FontCreate();
struct k3Tex *fnttexldr(struct k3Font *fnt, const char *name) {
return resman_ref(RESMAN_TEXTURE, name);
}
k3FontLoad(fnt, fntbuf, fntfsz, fnttexldr);
free(fntbuf);
k3FontLoad(fnt, namebuf);
res->thing = fnt;
return 1;

View File

@ -1909,7 +1909,7 @@ static int dagame_draw(lua_State *L) {
float b = lua_type(L, -2) == LUA_TNUMBER ? lua_tonumber(L, -2) : 1;
float a = lua_type(L, -1) == LUA_TNUMBER ? lua_tonumber(L, -1) : 1;
k3BatchAdd(tex, (struct k3RectF) {.x = sx, .y = sy, .w = sw, .h = sh}, (struct k3RectF) {.x = x, .y = y, .w = w, .h = h}, 0, (vec4) {r, g, b, a}, 0);
k3BatchAdd(tex, (struct k3RectF) {.x = sx, .y = sy, .w = sw, .h = sh}, (struct k3RectF) {.x = x, .y = y, .w = w, .h = h}, 0, (vec4) {r, g, b, a}, 0, 0);
lua_pop(L, 13);
} else {
@ -3373,7 +3373,8 @@ void luaapi_init() {
luaL_requiref(L, LUA_STRLIBNAME, luaopen_string, 1);
luaL_requiref(L, LUA_MATHLIBNAME, luaopen_math, 1);
luaL_requiref(L, LUA_DBLIBNAME, luaopen_debug, 1);
lua_pop(L, 5);
luaL_requiref(L, LUA_UTF8LIBNAME, luaopen_utf8, 1);
lua_pop(L, 6);
k3Log(k3_DEBUG, "Setting custom require");