summaryrefslogtreecommitdiff
path: root/src/text.c
diff options
context:
space:
mode:
authorjussi2022-02-22 15:06:23 +0200
committerjussi2022-02-22 15:06:23 +0200
commita7f58b3261565b59e508c659ae3a7f1964a5bad5 (patch)
treee9e337687923e0997885d1b55f735d82bf29c6ed /src/text.c
parent8800de59fa704cfe60ac980db079b44042639684 (diff)
downloadreilua-enhanced-a7f58b3261565b59e508c659ae3a7f1964a5bad5.tar.gz
reilua-enhanced-a7f58b3261565b59e508c659ae3a7f1964a5bad5.tar.bz2
reilua-enhanced-a7f58b3261565b59e508c659ae3a7f1964a5bad5.zip
Touch and gestures.
Diffstat (limited to 'src/text.c')
-rw-r--r--src/text.c69
1 files changed, 67 insertions, 2 deletions
diff --git a/src/text.c b/src/text.c
index bd6dea5..1089c1b 100644
--- a/src/text.c
+++ b/src/text.c
@@ -40,7 +40,7 @@ Load font from file into GPU memory ( VRAM )
- Failure return -1
- Success return int
*/
-int lmodelsLoadFont( lua_State *L ) {
+int ltextLoadFont( lua_State *L ) {
if ( !lua_isstring( L, -1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_LoadFont( string fileName )" );
lua_pushinteger( L, -1 );
@@ -62,6 +62,33 @@ int lmodelsLoadFont( lua_State *L ) {
}
/*
+> success = RL_UnloadFont( Font font )
+
+Unload Font from GPU memory ( VRAM )
+
+- Failure return false
+- Success return true
+*/
+int ltextUnloadFont( lua_State *L ) {
+ if ( !lua_isnumber( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_UnloadFont( Font font )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ size_t id = lua_tointeger( L, -1 );
+
+ if ( !validFont( id ) ) {
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ UnloadFont( *state->fonts[ id ] );
+ state->fonts[ id ] = NULL;
+ lua_pushboolean( L, true );
+
+ return 1;
+}
+
+/*
## Text - Draw
*/
@@ -116,9 +143,47 @@ int ltextDrawText( lua_State *L ) {
lua_pushboolean( L, false );
return 1;
}
-
DrawTextEx( *state->fonts[ fontId ], lua_tostring( L, -1 ), position, fontSize, spacing, color );
lua_pushboolean( L, true );
return 1;
}
+
+/*
+> success = RL_DrawTextPro( Font font, const char text, Vector2 position, Vector2 origin, float rotation, float fontSize, float spacing, Color tint )
+
+Draw text using Font and pro parameters ( rotation )
+
+- Failure return false
+- Success return true
+*/
+int ltextDrawTextPro( lua_State *L ) {
+ if ( !lua_isnumber( L, -8 ) || !lua_isstring( L, -7 ) || !lua_istable( L, -6 ) || !lua_istable( L, -5 )
+ || !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_DrawTextPro( Font font, const char text, Vector2 position, Vector2 origin, float rotation, float fontSize, float spacing, Color tint )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ Color color = uluaGetColor( L );
+ lua_pop( L, 1 );
+ float spacing = lua_tonumber( L, -1 );
+ lua_pop( L, 1 );
+ float fontSize = lua_tonumber( L, -1 );
+ lua_pop( L, 1 );
+ float rotation = lua_tonumber( L, -1 );
+ lua_pop( L, 1 );
+ Vector2 origin = uluaGetVector2( L );
+ lua_pop( L, 1 );
+ Vector2 position = uluaGetVector2( L );
+ lua_pop( L, 1 );
+ size_t fontId = lua_tointeger( L, -2 );
+
+ if ( !validFont( fontId ) ) {
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ DrawTextPro( *state->fonts[ fontId ], lua_tostring( L, -1 ), position, origin, rotation, fontSize, spacing, color );
+ lua_pushboolean( L, true );
+
+ return 1;
+}