Renamed Font:hasGlyph to Font:hasGlyphs, and expanded it to accept multiple arguments and full strings. Resolves issue #762.

This commit is contained in:
Alex Szpakowski
2013-10-25 21:56:32 -03:00
parent b57256b3e5
commit 4e321697d3
8 changed files with 51 additions and 26 deletions
+16 -7
View File
@@ -135,17 +135,26 @@ int w_Font_getBaseline(lua_State *L)
return 1;
}
int w_Font_hasGlyph(lua_State *L)
int w_Font_hasGlyphs(lua_State *L)
{
Font *t = luax_checkfont(L, 1);
bool hasglyph = false;
int count = lua_gettop(L) - 1;
count = count < 1 ? 1 : count;
EXCEPT_GUARD(
if (lua_type(L, 2) == LUA_TSTRING)
hasglyph = t->hasGlyph(luax_checkstring(L, 2));
else
hasglyph = t->hasGlyph((uint32) luaL_checknumber(L, 2));
)
for (int i = 2; i < count + 2; i++)
{
if (lua_type(L, i) == LUA_TSTRING)
hasglyph = t->hasGlyphs(luax_checkstring(L, i));
else
hasglyph = t->hasGlyph((uint32) luaL_checknumber(L, i));
if (!hasglyph)
break;
}
)
luax_pushboolean(L, hasglyph);
return 1;
@@ -163,7 +172,7 @@ static const luaL_Reg functions[] =
{ "getAscent", w_Font_getAscent },
{ "getDescent", w_Font_getDescent },
{ "getBaseline", w_Font_getBaseline },
{ "hasGlyph", w_Font_hasGlyph },
{ "hasGlyphs", w_Font_hasGlyphs },
{ 0, 0 }
};