|
@@ -93,8 +93,7 @@ int w_Font_getLineHeight(lua_State *L)
|
|
int w_Font_setFilter(lua_State *L)
|
|
int w_Font_setFilter(lua_State *L)
|
|
{
|
|
{
|
|
Font *t = luax_checkfont(L, 1);
|
|
Font *t = luax_checkfont(L, 1);
|
|
-
|
|
|
|
- Image::Filter f;
|
|
|
|
|
|
+ Image::Filter f = t->getFilter();
|
|
|
|
|
|
const char *minstr = luaL_checkstring(L, 2);
|
|
const char *minstr = luaL_checkstring(L, 2);
|
|
const char *magstr = luaL_optstring(L, 3, minstr);
|
|
const char *magstr = luaL_optstring(L, 3, minstr);
|
|
@@ -104,15 +103,6 @@ int w_Font_setFilter(lua_State *L)
|
|
if (!Image::getConstant(magstr, f.mag))
|
|
if (!Image::getConstant(magstr, f.mag))
|
|
return luaL_error(L, "Invalid filter mode: %s", magstr);
|
|
return luaL_error(L, "Invalid filter mode: %s", magstr);
|
|
|
|
|
|
- if (lua_isnoneornil(L, 4))
|
|
|
|
- f.mipmap = Image::FILTER_NONE; // mipmapping is disabled unless third argument is given
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- const char *mipmapstr = luaL_checkstring(L, 4);
|
|
|
|
- if (!Image::getConstant(mipmapstr, f.mipmap))
|
|
|
|
- return luaL_error(L, "Invalid filter mode: %s", mipmapstr);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
try
|
|
try
|
|
{
|
|
{
|
|
t->setFilter(f);
|
|
t->setFilter(f);
|
|
@@ -135,14 +125,47 @@ int w_Font_getFilter(lua_State *L)
|
|
Image::getConstant(f.mag, magstr);
|
|
Image::getConstant(f.mag, magstr);
|
|
lua_pushstring(L, minstr);
|
|
lua_pushstring(L, minstr);
|
|
lua_pushstring(L, magstr);
|
|
lua_pushstring(L, magstr);
|
|
|
|
+ return 2;
|
|
|
|
+}
|
|
|
|
|
|
- const char *mipmapstr;
|
|
|
|
- if (Image::getConstant(f.mipmap, mipmapstr))
|
|
|
|
- lua_pushstring(L, mipmapstr);
|
|
|
|
|
|
+int w_Font_setMipmapFilter(lua_State *L)
|
|
|
|
+{
|
|
|
|
+ Font *t = luax_checkfont(L, 1);
|
|
|
|
+ Image::Filter f = t->getFilter();
|
|
|
|
+
|
|
|
|
+ if (lua_isnoneornil(L, 2))
|
|
|
|
+ f.mipmap = Image::FILTER_NONE; // mipmapping is disabled if no argument is given
|
|
else
|
|
else
|
|
- lua_pushnil(L); // only return a mipmap filter if mipmapping is enabled
|
|
|
|
|
|
+ {
|
|
|
|
+ const char *mipmapstr = luaL_checkstring(L, 2);
|
|
|
|
+ if (!Image::getConstant(mipmapstr, f.mipmap))
|
|
|
|
+ return luaL_error(L, "Invalid filter mode: %s", mipmapstr);
|
|
|
|
+ }
|
|
|
|
|
|
- return 3;
|
|
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ t->setFilter(f);
|
|
|
|
+ }
|
|
|
|
+ catch(love::Exception &e)
|
|
|
|
+ {
|
|
|
|
+ return luaL_error(L, "%s", e.what());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+int w_Font_getMipmapFilter(lua_State *L)
|
|
|
|
+{
|
|
|
|
+ Font *t = luax_checkfont(L, 1);
|
|
|
|
+ const Image::Filter f = t->getFilter();
|
|
|
|
+
|
|
|
|
+ const char *mipmapstr;
|
|
|
|
+ if (!Image::getConstant(f.mipmap, mipmapstr))
|
|
|
|
+ return 0; // only return a mipmap filter if mipmapping is enabled
|
|
|
|
+
|
|
|
|
+ lua_pushstring(L, mipmapstr);
|
|
|
|
+
|
|
|
|
+ return 1;
|
|
}
|
|
}
|
|
|
|
|
|
int w_Font_setMipmapSharpness(lua_State *L)
|
|
int w_Font_setMipmapSharpness(lua_State *L)
|
|
@@ -162,6 +185,27 @@ int w_Font_getMipmapSharpness(lua_State *L)
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+int w_Font_getAscent(lua_State *L)
|
|
|
|
+{
|
|
|
|
+ Font *t = luax_checkfont(L, 1);
|
|
|
|
+ lua_pushnumber(L, t->getAscent());
|
|
|
|
+ return 1;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+int w_Font_getDescent(lua_State *L)
|
|
|
|
+{
|
|
|
|
+ Font *t = luax_checkfont(L, 1);
|
|
|
|
+ lua_pushnumber(L, t->getDescent());
|
|
|
|
+ return 1;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+int w_Font_getBaseline(lua_State *L)
|
|
|
|
+{
|
|
|
|
+ Font *t = luax_checkfont(L, 1);
|
|
|
|
+ lua_pushnumber(L, t->getBaseline());
|
|
|
|
+ return 1;
|
|
|
|
+}
|
|
|
|
+
|
|
static const luaL_Reg functions[] =
|
|
static const luaL_Reg functions[] =
|
|
{
|
|
{
|
|
{ "getHeight", w_Font_getHeight },
|
|
{ "getHeight", w_Font_getHeight },
|
|
@@ -171,8 +215,13 @@ static const luaL_Reg functions[] =
|
|
{ "getLineHeight", w_Font_getLineHeight },
|
|
{ "getLineHeight", w_Font_getLineHeight },
|
|
{ "setFilter", w_Font_setFilter },
|
|
{ "setFilter", w_Font_setFilter },
|
|
{ "getFilter", w_Font_getFilter },
|
|
{ "getFilter", w_Font_getFilter },
|
|
|
|
+ { "setMipmapFilter", w_Font_setMipmapFilter },
|
|
|
|
+ { "getMipmapFilter", w_Font_getMipmapFilter },
|
|
{ "setMipmapSharpness", w_Font_setMipmapSharpness },
|
|
{ "setMipmapSharpness", w_Font_setMipmapSharpness },
|
|
{ "getMipmapSharpness", w_Font_getMipmapSharpness },
|
|
{ "getMipmapSharpness", w_Font_getMipmapSharpness },
|
|
|
|
+ { "getAscent", w_Font_getAscent },
|
|
|
|
+ { "getDescent", w_Font_getDescent },
|
|
|
|
+ { "getBaseline", w_Font_getBaseline },
|
|
{ 0, 0 }
|
|
{ 0, 0 }
|
|
};
|
|
};
|
|
|
|
|