mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +02:00
Renamed Font:hasGlyph to Font:hasGlyphs, and expanded it to accept multiple arguments and full strings. Resolves issue #762.
This commit is contained in:
@@ -557,9 +557,9 @@ bool Font::hasGlyph(uint32 glyph) const
|
||||
return rasterizer->hasGlyph(glyph);
|
||||
}
|
||||
|
||||
bool Font::hasGlyph(const std::string &text) const
|
||||
bool Font::hasGlyphs(const std::string &text) const
|
||||
{
|
||||
return rasterizer->hasGlyph(text);
|
||||
return rasterizer->hasGlyphs(text);
|
||||
}
|
||||
|
||||
} // opengl
|
||||
|
||||
@@ -135,7 +135,7 @@ public:
|
||||
float getBaseline() const;
|
||||
|
||||
bool hasGlyph(uint32 glyph) const;
|
||||
bool hasGlyph(const std::string &text) const;
|
||||
bool hasGlyphs(const std::string &text) const;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -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 }
|
||||
};
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ int w_Font_getFilter(lua_State *L);
|
||||
int w_Font_getAscent(lua_State *L);
|
||||
int w_Font_getDescent(lua_State *L);
|
||||
int w_Font_getBaseline(lua_State *L);
|
||||
int w_Font_hasGlyph(lua_State *L);
|
||||
int w_Font_hasGlyphs(lua_State *L);
|
||||
extern "C" int luaopen_font(lua_State *L);
|
||||
|
||||
} // opengl
|
||||
|
||||
Reference in New Issue
Block a user