|
@@ -43,7 +43,14 @@ namespace opengl
|
|
{
|
|
{
|
|
Font * t = luax_checkfont(L, 1);
|
|
Font * t = luax_checkfont(L, 1);
|
|
const char * str = luaL_checkstring(L, 2);
|
|
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;
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -52,10 +59,18 @@ namespace opengl
|
|
Font * t = luax_checkfont(L, 1);
|
|
Font * t = luax_checkfont(L, 1);
|
|
const char * str = luaL_checkstring(L, 2);
|
|
const char * str = luaL_checkstring(L, 2);
|
|
float wrap = (float) luaL_checknumber(L, 3);
|
|
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, max_width);
|
|
- lua_pushinteger(L, lines.size());
|
|
|
|
|
|
+ lua_pushinteger(L, numlines);
|
|
return 2;
|
|
return 2;
|
|
}
|
|
}
|
|
|
|
|