mirror of
https://github.com/love2d/love.git
synced 2026-08-19 20:19:42 +02:00
Added Text:setFont.
This commit is contained in:
@@ -265,6 +265,16 @@ void Text::draw(float x, float y, float angle, float sx, float sy, float ox, flo
|
|||||||
glDisableVertexAttribArray(ATTRIB_POS);
|
glDisableVertexAttribArray(ATTRIB_POS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Text::setFont(Font *f)
|
||||||
|
{
|
||||||
|
font.set(f);
|
||||||
|
|
||||||
|
// Invalidate the texture cache ID since the font is different. We also have
|
||||||
|
// to re-upload all the vertices based on the new font's textures.
|
||||||
|
texture_cache_id = (uint32) -1;
|
||||||
|
regenerateVertices();
|
||||||
|
}
|
||||||
|
|
||||||
Font *Text::getFont() const
|
Font *Text::getFont() const
|
||||||
{
|
{
|
||||||
return font.get();
|
return font.get();
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ public:
|
|||||||
// Implements Drawable.
|
// Implements Drawable.
|
||||||
virtual void draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
|
virtual void draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
|
||||||
|
|
||||||
|
void setFont(Font *f);
|
||||||
Font *getFont() const;
|
Font *getFont() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -135,6 +135,14 @@ int w_Text_clear(lua_State *L)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int w_Text_setFont(lua_State *L)
|
||||||
|
{
|
||||||
|
Text *t = luax_checktext(L, 1);
|
||||||
|
Font *f = luax_checktype<Font>(L, 2, GRAPHICS_FONT_ID);
|
||||||
|
luax_catchexcept(L, [&](){ t->setFont(f); });
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int w_Text_getFont(lua_State *L)
|
int w_Text_getFont(lua_State *L)
|
||||||
{
|
{
|
||||||
Text *t = luax_checktext(L, 1);
|
Text *t = luax_checktext(L, 1);
|
||||||
@@ -164,6 +172,7 @@ static const luaL_Reg functions[] =
|
|||||||
{ "add", w_Text_add },
|
{ "add", w_Text_add },
|
||||||
{ "addf", w_Text_addf },
|
{ "addf", w_Text_addf },
|
||||||
{ "clear", w_Text_clear },
|
{ "clear", w_Text_clear },
|
||||||
|
{ "setFont", w_Text_setFont },
|
||||||
{ "getFont", w_Text_getFont },
|
{ "getFont", w_Text_getFont },
|
||||||
{ "getWidth", w_Text_getWidth },
|
{ "getWidth", w_Text_getWidth },
|
||||||
{ "getHeight", w_Text_getHeight },
|
{ "getHeight", w_Text_getHeight },
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ int w_Text_setf(lua_State *L);
|
|||||||
int w_Text_add(lua_State *L);
|
int w_Text_add(lua_State *L);
|
||||||
int w_Text_addf(lua_State *L);
|
int w_Text_addf(lua_State *L);
|
||||||
int w_Text_clear(lua_State *L);
|
int w_Text_clear(lua_State *L);
|
||||||
|
int w_Text_setFont(lua_State *L);
|
||||||
int w_Text_getFont(lua_State *L);
|
int w_Text_getFont(lua_State *L);
|
||||||
int w_Text_getWidth(lua_State *L);
|
int w_Text_getWidth(lua_State *L);
|
||||||
int w_Text_getHeight(lua_State *L);
|
int w_Text_getHeight(lua_State *L);
|
||||||
|
|||||||
Reference in New Issue
Block a user