Create Fonts from Rasterizers;
@@ -820,6 +820,11 @@ int l_lovrGraphicsNewCanvas(lua_State* L) {
}
int l_lovrGraphicsNewFont(lua_State* L) {
+ Rasterizer* rasterizer;
+ void** type;
+ if ((type = luax_totype(L, 1, Rasterizer)) != NULL) {
+ rasterizer = *type;
+ } else {
Blob* blob = NULL;
float size;
@@ -830,15 +835,16 @@ int l_lovrGraphicsNewFont(lua_State* L) {
size = luaL_optnumber(L, 2, 32);
}
- Rasterizer* rasterizer = lovrRasterizerCreate(blob, size);
- Font* font = lovrFontCreate(rasterizer);
- luax_pushtype(L, Font, font);
- lovrRelease(&font->ref);
+ rasterizer = lovrRasterizerCreate(blob, size);
if (blob) {
lovrRelease(&blob->ref);
}
+ }
+ Font* font = lovrFontCreate(rasterizer);
+ luax_pushtype(L, Font, font);
+ lovrRelease(&font->ref);
return 1;
}
