From 6e17282197320bfc3af6a225fb3d9e13194022fa Mon Sep 17 00:00:00 2001 From: jussi Date: Thu, 24 Aug 2023 20:19:13 +0300 Subject: GetFontTexture. --- src/text.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'src/text.c') diff --git a/src/text.c b/src/text.c index bc14828..0339aa6 100644 --- a/src/text.c +++ b/src/text.c @@ -286,7 +286,7 @@ int ltextMeasureText( lua_State *L ) { /* > baseSize = RL.GetFontBaseSize( Font font ) -Get font baseSize +Get font base size ( default chars height ) - Failure return false - Success return int @@ -311,7 +311,7 @@ int ltextGetFontBaseSize( lua_State *L ) { /* > glyphCount = RL.GetFontGlyphCount( Font font ) -Get font glyphCount +Get font number of glyph characters - Failure return false - Success return int @@ -336,7 +336,7 @@ int ltextGetFontGlyphCount( lua_State *L ) { /* > glyphPadding = RL.GetFontGlyphPadding( Font font ) -Get font glyphPadding +Get font padding around the glyph characters - Failure return false - Success return int @@ -357,3 +357,28 @@ int ltextGetFontGlyphPadding( lua_State *L ) { return 1; } + +/* +> textureTable = RL.GetFontTexture( Font font ) + +Get font texture atlas containing the glyphs. NOTE! Texture in table form. + +- Failure return false +- Success return table +*/ +int ltextGetFontTexture( lua_State *L ) { + if ( !lua_isnumber( L, 1 ) ) { + TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GetFontTexture( Font font )" ); + lua_pushboolean( L, false ); + return 1; + } + size_t fontId = lua_tointeger( L, 1 ); + + if ( !validFont( fontId ) ) { + lua_pushboolean( L, false ); + return 1; + } + uluaPushTexture( L, state->fonts[ fontId ]->texture ); + + return 1; +} -- cgit v1.2.3