diff options
| author | Indrajith K L | 2025-11-04 17:31:31 +0530 |
|---|---|---|
| committer | Indrajith K L | 2025-11-04 17:31:31 +0530 |
| commit | 087700245e14273a498d1dd2f79f2698e56f94e0 (patch) | |
| tree | 78b7f13909d3246d08d8c2e4b03f3798a3705ca4 | |
| parent | cc4a5f53098dfdaf8cbebe81c3e34658694a2916 (diff) | |
| download | reilua-enhanced-087700245e14273a498d1dd2f79f2698e56f94e0.tar.gz reilua-enhanced-087700245e14273a498d1dd2f79f2698e56f94e0.tar.bz2 reilua-enhanced-087700245e14273a498d1dd2f79f2698e56f94e0.zip | |
Use Oleaguid as default font instead of Raylib default
| -rw-r--r-- | src/state.c | 22 | ||||
| -rw-r--r-- | src/text.c | 2 |
2 files changed, 19 insertions, 5 deletions
diff --git a/src/state.c b/src/state.c index d05416a..4fdc729 100644 --- a/src/state.c +++ b/src/state.c @@ -53,17 +53,31 @@ bool stateInit( int argn, const char** argc, const char* basePath ) { SetTextureFilter( state->defaultFont.texture, TEXTURE_FILTER_POINT ); state->customFontLoaded = true; #else - /* Load from file (development mode) */ + /* Load from file (development mode) - try both executable directory and working directory */ char fontPath[STRING_LEN]; - snprintf( fontPath, STRING_LEN, "%sfonts/Oleaguid.ttf", state->basePath ); - + bool fontFound = false; + + /* Try executable directory first */ + snprintf( fontPath, STRING_LEN, "%s/fonts/Oleaguid.ttf", GetApplicationDirectory() ); if ( FileExists( fontPath ) ) { + fontFound = true; + } + else { + /* Try working directory */ + snprintf( fontPath, STRING_LEN, "%s/fonts/Oleaguid.ttf", GetWorkingDirectory() ); + if ( FileExists( fontPath ) ) { + fontFound = true; + } + } + + if ( fontFound ) { state->defaultFont = LoadFontEx( fontPath, 48, NULL, 0 ); SetTextureFilter( state->defaultFont.texture, TEXTURE_FILTER_POINT ); state->customFontLoaded = true; + TraceLog( LOG_INFO, "Loaded custom font: %s", fontPath ); } else { - TraceLog( LOG_WARNING, "Custom font not found at '%s', using default font", fontPath ); + TraceLog( LOG_WARNING, "Custom font not found, using Raylib default font" ); state->defaultFont = GetFontDefault(); state->customFontLoaded = false; } @@ -495,7 +495,7 @@ int ltextDrawText( lua_State* L ) { float fontSize = luaL_checknumber( L, 3 ); Color tint = uluaGetColor( L, 4 ); - DrawText( luaL_checkstring( L, 1 ), position.x, position.y, fontSize, tint ); + DrawTextEx( state->defaultFont, luaL_checkstring( L, 1 ), position, fontSize, fontSize/10, tint ); return 0; } |
