mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-30 08:51:10 +02:00
CLuaInstance: Add function getRenderWidth()
This commit is contained in:
@@ -340,6 +340,7 @@ const luaL_Reg CLuaInstance::methods[] =
|
||||
{ "PaintIcon", CLuaInstance::PaintIcon },
|
||||
{ "GetInput", CLuaInstance::GetInput },
|
||||
{ "FontHeight", CLuaInstance::FontHeight },
|
||||
{ "getRenderWidth", CLuaInstance::getRenderWidth },
|
||||
{ "GetSize", CLuaInstance::GetSize },
|
||||
{ "DisplayImage", CLuaInstance::DisplayImage },
|
||||
{ "Blit", CLuaInstance::Blit },
|
||||
@@ -555,6 +556,24 @@ int CLuaInstance::RenderString(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CLuaInstance::getRenderWidth(lua_State *L)
|
||||
{
|
||||
int f;
|
||||
const char *text;
|
||||
DBG("CLuaInstance::%s %d\n", __func__, lua_gettop(L));
|
||||
|
||||
CLuaData *W = CheckData(L, 1);
|
||||
if (!W)
|
||||
return 0;
|
||||
f = luaL_checkint(L, 2); /* font number, use FONT['xxx'] for FONT_TYPE_xxx in the script */
|
||||
text = luaL_checkstring(L, 3); /* text */
|
||||
if (f >= SNeutrinoSettings::FONT_TYPE_COUNT || f < 0)
|
||||
f = SNeutrinoSettings::FONT_TYPE_MENU;
|
||||
|
||||
lua_pushinteger(L, (int)g_Font[f]->getRenderWidth(text, true));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CLuaInstance::GetInput(lua_State *L)
|
||||
{
|
||||
int numargs = lua_gettop(L);
|
||||
|
Reference in New Issue
Block a user