summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIndrajith K L2025-11-04 17:32:33 +0530
committerGitHub2025-11-04 17:32:33 +0530
commit2d565e5bcb0e2eab93d9d1bab520bbbaf7457a07 (patch)
tree78b7f13909d3246d08d8c2e4b03f3798a3705ca4
parentcc4a5f53098dfdaf8cbebe81c3e34658694a2916 (diff)
parent087700245e14273a498d1dd2f79f2698e56f94e0 (diff)
downloadreilua-enhanced-2d565e5bcb0e2eab93d9d1bab520bbbaf7457a07.tar.gz
reilua-enhanced-2d565e5bcb0e2eab93d9d1bab520bbbaf7457a07.tar.bz2
reilua-enhanced-2d565e5bcb0e2eab93d9d1bab520bbbaf7457a07.zip
Merge pull request #7 from cooljith91112/feature/font-updates
Use Oleaguid as default font
-rw-r--r--src/state.c22
-rw-r--r--src/text.c2
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;
}
diff --git a/src/text.c b/src/text.c
index 914a75d..5f2a91a 100644
--- a/src/text.c
+++ b/src/text.c
@@ -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;
}