Browse Source

Revert change that added codepoint variant of Font:getWidth.

It could break code that relied on Lua's implicit conversion from numbers to strings.
Alex Szpakowski 4 years ago
parent
commit
aa8ed7c8c5
2 changed files with 2 additions and 11 deletions
  1. 0 1
      changes.txt
  2. 2 10
      src/modules/graphics/wrap_Font.cpp

+ 0 - 1
changes.txt

@@ -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
src/modules/graphics/wrap_Font.cpp

@@ -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;
 }