Add configurable font path/font size.

This commit is contained in:
Themaister 2011-01-23 02:48:06 +01:00
parent 4e78b80343
commit 21b9f57af1
6 changed files with 35 additions and 7 deletions

View File

@ -100,6 +100,9 @@ static const bool video_smooth = true;
// On resize and fullscreen, rendering area will stay 4:3 // On resize and fullscreen, rendering area will stay 4:3
static const bool force_aspect = true; static const bool force_aspect = true;
// Font size for on-screen messages.
static const unsigned font_size = 48;
#define SNES_ASPECT_RATIO (4.0/3) #define SNES_ASPECT_RATIO (4.0/3)
//////////////// ////////////////

View File

@ -54,6 +54,10 @@ struct settings
char cg_shader_path[256]; char cg_shader_path[256];
char bsnes_shader_path[256]; char bsnes_shader_path[256];
unsigned filter; unsigned filter;
#ifdef HAVE_FREETYPE
char font_path[256];
unsigned font_size;
#endif
} video; } video;
struct struct

View File

@ -173,10 +173,10 @@ static inline void gl_shader_set_params(unsigned width, unsigned height,
/////////////////// ///////////////////
//////////////// Message rendering //////////////// Message rendering
static inline void gl_init_font(gl_t *gl, const char *font_path) static inline void gl_init_font(gl_t *gl, const char *font_path, unsigned font_size)
{ {
#ifdef HAVE_FREETYPE #ifdef HAVE_FREETYPE
gl->font = font_renderer_new(font_path, 48); gl->font = font_renderer_new(font_path, font_size);
if (gl->font) if (gl->font)
{ {
glGenTextures(1, &gl->font_tex); glGenTextures(1, &gl->font_tex);
@ -535,7 +535,7 @@ static void* gl_init(video_info_t *video, const input_driver_t **input, void **i
else else
*input = NULL; *input = NULL;
gl_init_font(gl, "/usr/share/fonts/TTF/DroidSans.ttf"); gl_init_font(gl, g_settings.video.font_path, g_settings.video.font_size);
if (!gl_check_error()) if (!gl_check_error())
{ {

View File

@ -102,6 +102,11 @@ static void set_defaults(void)
g_settings.video.filter = FILTER_NONE; g_settings.video.filter = FILTER_NONE;
#endif #endif
#ifdef HAVE_FREETYPE
strncpy(g_settings.video.font_path, "/usr/share/fonts/TTF/DejaVuSans.ttf", sizeof(g_settings.video.font_path) - 1);
g_settings.video.font_size = font_size;
#endif
g_settings.audio.enable = audio_enable; g_settings.audio.enable = audio_enable;
g_settings.audio.out_rate = out_rate; g_settings.audio.out_rate = out_rate;
g_settings.audio.in_rate = in_rate; g_settings.audio.in_rate = in_rate;
@ -232,10 +237,20 @@ static void parse_config_file(void)
if (config_get_string(conf, "video_bsnes_shader", &tmp_str)) if (config_get_string(conf, "video_bsnes_shader", &tmp_str))
{ {
strncpy(g_settings.video.bsnes_shader_path, tmp_str, sizeof(g_settings.video.bsnes_shader_path)); strncpy(g_settings.video.bsnes_shader_path, tmp_str, sizeof(g_settings.video.bsnes_shader_path) - 1);
free(tmp_str); free(tmp_str);
} }
if (config_get_string(conf, "video_font_path", &tmp_str))
{
strncpy(g_settings.video.font_path, tmp_str, sizeof(g_settings.video.font_path) - 1);
free(tmp_str);
}
if (config_get_int(conf, "video_font_size", &tmp_int))
g_settings.video.font_size = tmp_int;
#ifdef HAVE_FILTER #ifdef HAVE_FILTER
if (config_get_string(conf, "video_filter", &tmp_str)) if (config_get_string(conf, "video_filter", &tmp_str))
{ {

View File

@ -674,7 +674,7 @@ int main(int argc, char *argv[])
bool should_savestate = driver.input->key_pressed(driver.input_data, SSNES_SAVE_STATE_KEY); bool should_savestate = driver.input->key_pressed(driver.input_data, SSNES_SAVE_STATE_KEY);
if (should_savestate && !old_should_savestate) if (should_savestate && !old_should_savestate)
{ {
msg_queue_push(g_extern.msg_queue, "Saving state! :D", 1, 180); msg_queue_push(g_extern.msg_queue, "Saving state! ^_^", 1, 180);
save_state(g_extern.savestate_name); save_state(g_extern.savestate_name);
} }
old_should_savestate = should_savestate; old_should_savestate = should_savestate;
@ -683,7 +683,7 @@ int main(int argc, char *argv[])
bool should_loadstate = driver.input->key_pressed(driver.input_data, SSNES_LOAD_STATE_KEY); bool should_loadstate = driver.input->key_pressed(driver.input_data, SSNES_LOAD_STATE_KEY);
if (!should_savestate && should_loadstate && !old_should_loadstate) if (!should_savestate && should_loadstate && !old_should_loadstate)
{ {
msg_queue_push(g_extern.msg_queue, "Loading state! :D", 1, 180); msg_queue_push(g_extern.msg_queue, "Loading state! ^_^", 1, 180);
load_state(g_extern.savestate_name); load_state(g_extern.savestate_name);
} }
old_should_loadstate = should_loadstate; old_should_loadstate = should_loadstate;

View File

@ -37,6 +37,12 @@
# CPU-based filter. Valid ones are: hq2x, hq4x, grayscale, bleed, ntsc. # CPU-based filter. Valid ones are: hq2x, hq4x, grayscale, bleed, ntsc.
# video_filter = ntsc # video_filter = ntsc
# Path to a TTF font used for rendering messages.
# video_font_path =
# Size of the TTF font rendered.
# video_font_size = 48
#### Audio #### Audio
# Enable audio. # Enable audio.