summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjussi2024-09-26 23:02:13 +0300
committerjussi2024-09-26 23:02:13 +0300
commitd3202073a72b4ff0f98c29cdb096e2747dbaaae8 (patch)
treecbab46cfe511676f513911befef96e0053a76649 /src
parent45e11be96a7503a0cfe29bbbcc8d885d81ab9591 (diff)
downloadreilua-enhanced-d3202073a72b4ff0f98c29cdb096e2747dbaaae8.tar.gz
reilua-enhanced-d3202073a72b4ff0f98c29cdb096e2747dbaaae8.tar.bz2
reilua-enhanced-d3202073a72b4ff0f98c29cdb096e2747dbaaae8.zip
FontCopy.
Diffstat (limited to 'src')
-rw-r--r--src/lua_core.c1
-rw-r--r--src/rgui.c13
-rw-r--r--src/state.c2
-rw-r--r--src/text.c15
4 files changed, 24 insertions, 7 deletions
diff --git a/src/lua_core.c b/src/lua_core.c
index 7250cfc..508158d 100644
--- a/src/lua_core.c
+++ b/src/lua_core.c
@@ -1834,6 +1834,7 @@ void luaRegister() {
assingGlobalFunction( "LoadFontFromImage", ltextLoadFontFromImage );
assingGlobalFunction( "LoadFontFromMemory", ltextLoadFontFromMemory );
assingGlobalFunction( "LoadFontFromData", ltextLoadFontFromData );
+ assingGlobalFunction( "FontCopy", ltextFontCopy );
assingGlobalFunction( "IsFontReady", ltextIsFontReady );
assingGlobalFunction( "LoadFontData", ltextLoadFontData );
assingGlobalFunction( "GenImageFontAtlas", ltextGenImageFontAtlas );
diff --git a/src/rgui.c b/src/rgui.c
index 0a4152d..106180e 100644
--- a/src/rgui.c
+++ b/src/rgui.c
@@ -129,7 +129,8 @@ int lguiGuiSetFont( lua_State* L ) {
Font* font = uluaGetFont( L, 1 );
GuiSetFont( *font );
- state->guiDefaultFont = GuiGetFont();
+ // state->guiFont = GuiGetFont();
+ state->guiFont = *font;
return 0;
}
@@ -137,12 +138,12 @@ int lguiGuiSetFont( lua_State* L ) {
/*
> font = RL.GuiGetFont()
-Get gui custom font (global state). Return as lightuserdata
+Get gui font (global state). Return as lightuserdata
- Success return Font
*/
int lguiGuiGetFont( lua_State* L ) {
- lua_pushlightuserdata( L, &state->guiDefaultFont );
+ lua_pushlightuserdata( L, &state->guiFont );
return 1;
}
@@ -162,7 +163,6 @@ int lguiGuiSetStyle( lua_State* L ) {
int value = luaL_checkinteger( L, 3 );
GuiSetStyle( control, property, value );
- state->guiDefaultFont = GuiGetFont();
return 0;
}
@@ -198,11 +198,12 @@ Load style file over global style variable (.rgs)
int lguiGuiLoadStyle( lua_State* L ) {
if ( FileExists( luaL_checkstring( L, 1 ) ) ) {
GuiLoadStyle( lua_tostring( L, 1 ) );
+ state->guiFont = GuiGetFont();
lua_pushboolean( L, true );
return 1;
}
- state->guiDefaultFont = GuiGetFont();
+ // state->guiFont = GuiGetFont();
TraceLog( state->logLevelInvalid, "Invalid file '%s'", lua_tostring( L, 1 ) );
lua_pushnil( L );
@@ -216,7 +217,7 @@ Load style default over global style
*/
int lguiGuiLoadStyleDefault( lua_State* L ) {
GuiLoadStyleDefault();
- state->guiDefaultFont = GuiGetFont();
+ state->guiFont = GuiGetFont();
return 0;
}
diff --git a/src/state.c b/src/state.c
index 0fed44e..70045de 100644
--- a/src/state.c
+++ b/src/state.c
@@ -32,7 +32,7 @@ bool stateInit( int argn, const char** argc, const char* basePath ) {
state->run = luaInit( argn, argc );
}
state->defaultFont = GetFontDefault();
- state->guiDefaultFont = GuiGetFont();
+ state->guiFont = GuiGetFont();
state->defaultMaterial = LoadMaterialDefault();
state->defaultTexture = (Texture){ 1, 1, 1, 1, 7 };
state->RLGLcurrentShaderLocs = malloc( RL_MAX_SHADER_LOCATIONS * sizeof( int ) );
diff --git a/src/text.c b/src/text.c
index 71bf14f..309f6da 100644
--- a/src/text.c
+++ b/src/text.c
@@ -280,6 +280,21 @@ int ltextLoadFontFromData( lua_State* L ) {
}
/*
+> font = RL.FontCopy( Font font )
+
+Load font copy as new userdata
+
+- Success return Font
+*/
+int ltextFontCopy( lua_State* L ) {
+ Font* font = uluaGetFont( L, 1 );
+
+ uluaPushFont( L, *font );
+
+ return 1;
+}
+
+/*
> isReady = RL.IsFontReady( Font font )
Check if a font is ready