mirror of
https://github.com/love2d/love.git
synced 2026-08-15 15:51:12 +02:00
This commit is contained in:
@@ -43,7 +43,14 @@ namespace opengl
|
||||
{
|
||||
Font * t = luax_checkfont(L, 1);
|
||||
const char * str = luaL_checkstring(L, 2);
|
||||
lua_pushinteger(L, t->getWidth(str));
|
||||
try
|
||||
{
|
||||
lua_pushinteger(L, t->getWidth(str));
|
||||
}
|
||||
catch (love::Exception & e)
|
||||
{
|
||||
return luaL_error(L, e.what());
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -52,10 +59,18 @@ namespace opengl
|
||||
Font * t = luax_checkfont(L, 1);
|
||||
const char * str = luaL_checkstring(L, 2);
|
||||
float wrap = (float) luaL_checknumber(L, 3);
|
||||
int max_width = 0;
|
||||
std::vector<std::string> lines = t->getWrap(str, wrap, &max_width);
|
||||
int max_width = 0, numlines = 0;
|
||||
try
|
||||
{
|
||||
std::vector<std::string> lines = t->getWrap(str, wrap, &max_width);
|
||||
numlines = lines.size();
|
||||
}
|
||||
catch (love::Exception & e)
|
||||
{
|
||||
return luaL_error(L, e.what());
|
||||
}
|
||||
lua_pushinteger(L, max_width);
|
||||
lua_pushinteger(L, lines.size());
|
||||
lua_pushinteger(L, numlines);
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user