Merge pull request #7 from cooljith91112/feature/font-updates
Use Oleaguid as default font
This commit is contained in:
20
src/state.c
20
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user