Пример #1
0
int LuaFonts::GetTextHeight(lua_State* L)
{
	CglFont* font = tofont(L, 1);
	const string text(luaL_checkstring(L, 2),lua_strlen(L, 2));
	float descender;
	int lines;
	const float height = font->GetTextHeight(text,&descender,&lines);
	lua_pushnumber(L, height);
	lua_pushnumber(L, descender);
	lua_pushnumber(L, lines);
	return 3;
}
Пример #2
0
int LuaFonts::GetTextHeight(lua_State* L)
{
	CglFont* font = tofont(L, 1);

	const int args = lua_gettop(L); // number of arguments
	if ((args < 2) || !lua_isstring(L, 2)) {
		luaL_error(L, "Incorrect arguments to font:GetTextHeight(\"text\")");
	}

	const string text(lua_tostring(L, 2),lua_strlen(L, 2));
	float descender;
	int lines;

	const float height = font->GetTextHeight(text,&descender,&lines);
	lua_pushnumber(L, height);
	lua_pushnumber(L, descender);
	lua_pushnumber(L, lines);
	return 3;
}