Revert change that added codepoint variant of Font:getWidth.

It could break code that relied on Lua's implicit conversion from numbers to strings.
This commit is contained in:
Alex Szpakowski
2021-05-30 15:46:21 -03:00
parent 4fe21d40d1
commit aa8ed7c8c5
2 changed files with 2 additions and 11 deletions
-1
View File
@@ -5,7 +5,6 @@ Released: N/A
* Added Body:getLocalPoints.
* Added Font:getKerning.
* Added a variant of Font:getWidth which takes a codepoint number argument.
* Added support for r16, rg16, and rgba16 pixel formats in Canvases.
* Added Shader:send(name, matrixlayout, data, ...) variant, whose argument order is more consistent than Shader:send(name, data, matrixlayout, ...).
+2 -10
View File
@@ -86,16 +86,8 @@ int w_Font_getHeight(lua_State *L)
int w_Font_getWidth(lua_State *L)
{
Font *t = luax_checkfont(L, 1);
if (lua_type(L, 2) == LUA_TSTRING)
{
const char *str = luaL_checkstring(L, 2);
luax_catchexcept(L, [&](){ lua_pushinteger(L, t->getWidth(str)); });
}
else
{
uint32 glyph = (uint32) luaL_checknumber(L, 2);
luax_catchexcept(L, [&](){ lua_pushinteger(L, t->getWidth(glyph)); });
}
const char *str = luaL_checkstring(L, 2);
luax_catchexcept(L, [&](){ lua_pushinteger(L, t->getWidth(str)); });
return 1;
}