summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;
}