mirror of https://github.com/bjornbytes/lovr.git
More Font APIs;
This commit is contained in:
parent
71f6a88a62
commit
499cf9c0dc
|
@ -1,7 +1,33 @@
|
|||
#include "api.h"
|
||||
#include "graphics/graphics.h"
|
||||
#include "util.h"
|
||||
#include <lua.h>
|
||||
#include <lauxlib.h>
|
||||
|
||||
static int l_lovrFontGetRasterizer(lua_State* L) {
|
||||
Font* font = luax_checktype(L, 1, Font);
|
||||
const FontInfo* info = lovrFontGetInfo(font);
|
||||
luax_pushtype(L, Rasterizer, info->rasterizer);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int l_lovrFontGetPixelDensity(lua_State* L) {
|
||||
Font* font = luax_checktype(L, 1, Font);
|
||||
float density = lovrFontGetPixelDensity(font);
|
||||
lua_pushnumber(L, density);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int l_lovrFontSetPixelDensity(lua_State* L) {
|
||||
Font* font = luax_checktype(L, 1, Font);
|
||||
float pixelDensity = luax_optfloat(L, 2, 0.f);
|
||||
lovrFontSetPixelDensity(font, pixelDensity);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const luaL_Reg lovrFont[] = {
|
||||
{ "getRasterizer", l_lovrFontGetRasterizer },
|
||||
{ "getPixelDensity", l_lovrFontGetPixelDensity },
|
||||
{ "setPixelDensity", l_lovrFontSetPixelDensity },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
|
|
@ -628,7 +628,7 @@ void lovrGraphicsSetBackground(float background[4]) {
|
|||
Font* lovrGraphicsGetDefaultFont() {
|
||||
if (!state.defaultFont) {
|
||||
state.defaultFont = lovrFontCreate(&(FontInfo) {
|
||||
.rasterizer = lovrRasterizerCreate(NULL, 48),
|
||||
.rasterizer = lovrRasterizerCreate(NULL, 32),
|
||||
.padding = 1,
|
||||
.spread = 4.
|
||||
});
|
||||
|
@ -1738,6 +1738,10 @@ void lovrFontDestroy(void* ref) {
|
|||
free(font);
|
||||
}
|
||||
|
||||
const FontInfo* lovrFontGetInfo(Font* font) {
|
||||
return &font->info;
|
||||
}
|
||||
|
||||
float lovrFontGetPixelDensity(Font* font) {
|
||||
return font->pixelDensity;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue