diff options
| author | Indrajith K L | 2025-11-05 02:24:08 +0530 |
|---|---|---|
| committer | GitHub | 2025-11-05 02:24:08 +0530 |
| commit | 8c4b587a2347a911d165f0b4afcce116970ad7e5 (patch) | |
| tree | 9116d4b6e0e0063e6b509c78f81354cb5faf3d74 /src | |
| parent | 10c22d35678f96e722f25a12badca98febb2921e (diff) | |
| parent | 7f014770c0ad7f20c70cca1b81b71751d9fbc7c5 (diff) | |
| download | reilua-enhanced-8c4b587a2347a911d165f0b4afcce116970ad7e5.tar.gz reilua-enhanced-8c4b587a2347a911d165f0b4afcce116970ad7e5.tar.bz2 reilua-enhanced-8c4b587a2347a911d165f0b4afcce116970ad7e5.zip | |
Merge pull request #8 from cooljith91112/feature/font-rendering
Fix font antialiasing and improve UX
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.c | 2 | ||||
| -rw-r--r-- | src/text.c | 32 |
2 files changed, 22 insertions, 12 deletions
@@ -142,7 +142,7 @@ int main( int argn, const char** argc ) { splashInit(); bool splashDone = false; - while ( !splashDone && !WindowShouldClose() ) { + while ( !splashDone ) { float delta = GetFrameTime(); splashDone = splashUpdate( delta ); splashDraw(); @@ -185,7 +185,9 @@ Load font from file into GPU memory (VRAM) */ int ltextLoadFont( lua_State* L ) { if ( FileExists( luaL_checkstring( L, 1 ) ) ) { - uluaPushFont( L, LoadFont( lua_tostring( L, 1 ) ) ); + Font font = LoadFont( lua_tostring( L, 1 ) ); + SetTextureFilter( font.texture, TEXTURE_FILTER_POINT ); + uluaPushFont( L, font ); return 1; } @@ -207,16 +209,19 @@ int ltextLoadFontEx( lua_State* L ) { int fontSize = luaL_checkinteger( L, 2 ); if ( FileExists( luaL_checkstring( L, 1 ) ) ) { + Font font; if ( lua_istable( L, 3 ) ) { int codepointCount = uluaGetTableLen( L, 3 ); int codepoints[ codepointCount ]; getCodepoints( L, codepoints, 3 ); - uluaPushFont( L, LoadFontEx( lua_tostring( L, 1 ), fontSize, codepoints, codepointCount ) ); - - return 1; + font = LoadFontEx( lua_tostring( L, 1 ), fontSize, codepoints, codepointCount ); + } + else { + font = LoadFontEx( lua_tostring( L, 1 ), fontSize, NULL, 0 ); } - uluaPushFont( L, LoadFontEx( lua_tostring( L, 1 ), fontSize, NULL, 0 ) ); + SetTextureFilter( font.texture, TEXTURE_FILTER_POINT ); + uluaPushFont( L, font ); return 1; } @@ -238,7 +243,9 @@ int ltextLoadFontFromImage( lua_State* L ) { Color key = uluaGetColor( L, 2 ); int firstChar = luaL_checkinteger( L, 3 ); - uluaPushFont( L, LoadFontFromImage( *image, key, firstChar ) ); + Font font = LoadFontFromImage( *image, key, firstChar ); + SetTextureFilter( font.texture, TEXTURE_FILTER_POINT ); + uluaPushFont( L, font ); return 1; } @@ -255,17 +262,20 @@ int ltextLoadFontFromMemory( lua_State* L ) { Buffer* fileData = uluaGetBuffer( L, 2 ); int fontSize = luaL_checkinteger( L, 3 ); + Font font; if ( lua_istable( L, 4 ) ) { int codepointCount = uluaGetTableLen( L, 4 ); int codepoints[ codepointCount ]; getCodepoints( L, codepoints, 4 ); - uluaPushFont( L, LoadFontFromMemory( fileType, fileData->data, fileData->size, fontSize, codepoints, codepointCount ) ); - - return 1; + font = LoadFontFromMemory( fileType, fileData->data, fileData->size, fontSize, codepoints, codepointCount ); } - /* If no codepoints provided. */ - uluaPushFont( L, LoadFontFromMemory( fileType, fileData->data, fileData->size, fontSize, NULL, 0 ) ); + else { + /* If no codepoints provided. */ + font = LoadFontFromMemory( fileType, fileData->data, fileData->size, fontSize, NULL, 0 ); + } + SetTextureFilter( font.texture, TEXTURE_FILTER_POINT ); + uluaPushFont( L, font ); return 1; } |
