From 05eaafb79e6fa1bebff157e94563334d7ead700b Mon Sep 17 00:00:00 2001 From: jussi Date: Mon, 20 Nov 2023 21:04:53 +0200 Subject: Initial changes for Raylib 5.0 and some missing functions. --- src/text.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'src/text.c') diff --git a/src/text.c b/src/text.c index af7b02f..a6e0241 100644 --- a/src/text.c +++ b/src/text.c @@ -193,9 +193,9 @@ int ltextLoadFont( lua_State *L ) { } /* -> font = RL.LoadFontEx( string fileName, int fontSize, int{} fontChars ) +> font = RL.LoadFontEx( string fileName, int fontSize, int{} codepoints ) -Load font from file with extended parameters, use NULL for fontChars to load the default character set +Load font from file with extended parameters, use NULL for codepoints to load the default character set - Failure return nil - Success return Font @@ -205,20 +205,20 @@ int ltextLoadFontEx( lua_State *L ) { if ( FileExists( luaL_checkstring( L, 1 ) ) ) { if ( lua_istable( L, 3 ) ) { - int glyphCount = uluaGetTableLen( L, 3 ); - int fontChars[ glyphCount ]; + int codepointCount = uluaGetTableLen( L, 3 ); + int codepoints[ codepointCount ]; int t = 3; int i = 0; lua_pushnil( L ); while ( lua_next( L, t ) != 0 ) { - fontChars[i] = lua_tointeger( L, -1 ); + codepoints[i] = lua_tointeger( L, -1 ); i++; lua_pop( L, 1 ); } - uluaPushFont( L, LoadFontEx( lua_tostring( L, 1 ), fontSize, fontChars, glyphCount ) ); + uluaPushFont( L, LoadFontEx( lua_tostring( L, 1 ), fontSize, codepoints, codepointCount ) ); return 1; } @@ -374,8 +374,8 @@ int ltextDrawTextCodepoints( lua_State *L ) { float spacing = luaL_checknumber( L, 5 ); Color tint = uluaGetColor( L, 6 ); - int count = uluaGetTableLen( L, 2 ); - int codepoints[ count ]; + int codepointCount = uluaGetTableLen( L, 2 ); + int codepoints[ codepointCount ]; int t = 2; int i = 0; @@ -387,7 +387,7 @@ int ltextDrawTextCodepoints( lua_State *L ) { i++; lua_pop( L, 1 ); } - DrawTextCodepoints( *font, codepoints, count, position, fontSize, spacing, tint ); + DrawTextCodepoints( *font, codepoints, codepointCount, position, fontSize, spacing, tint ); return 0; } @@ -460,6 +460,17 @@ int ltextDrawTextBoxedTinted( lua_State *L ) { ## Text - Text font info functions */ +/* +> size = RL.SetTextLineSpacing( int spacing ) + +Set vertical line spacing when drawing with line-breaks +*/ +int ltextSetTextLineSpacing( lua_State *L ) { + int spacing = luaL_checkinteger( L, 1 ); + + SetTextLineSpacing( spacing ); +} + /* > size = RL.MeasureText( Font font, string text, float fontSize, float spacing ) -- cgit v1.2.3