Font scale option.

This commit is contained in:
Themaister 2012-01-11 22:52:25 +01:00
parent c6fc8e45ff
commit 4eab7c4387
5 changed files with 16 additions and 3 deletions

View File

@ -170,6 +170,9 @@ static const bool crop_overscan = true;
// Font size for on-screen messages.
static const unsigned font_size = 48;
// Attempt to scale the font size.
// The scale factor will be window_size / desktop_size.
static const bool font_scale = true;
// Offset for where messages will be placed on-screen. Values are in range [0.0, 1.0].
static const float message_pos_offset_x = 0.05;

View File

@ -109,6 +109,7 @@ struct settings
char font_path[PATH_MAX];
unsigned font_size;
bool font_enable;
bool font_scale;
float msg_pos_x;
float msg_pos_y;
float msg_color_r;

View File

@ -756,10 +756,14 @@ static void blit_fonts(gl_t *gl, const struct font_output *head, const struct fo
static void calculate_font_coords(gl_t *gl,
GLfloat font_vertex[8], GLfloat font_vertex_dark[8], GLfloat font_tex_coords[8])
{
GLfloat scale_factor = g_settings.video.font_scale ?
gl->full_x / gl->vp_width :
1.0f;
GLfloat lx = g_settings.video.msg_pos_x;
GLfloat hx = (GLfloat)gl->font_last_width / gl->vp_width + lx;
GLfloat hx = (GLfloat)gl->font_last_width / (gl->vp_width * scale_factor) + lx;
GLfloat ly = g_settings.video.msg_pos_y;
GLfloat hy = (GLfloat)gl->font_last_height / gl->vp_height + ly;
GLfloat hy = (GLfloat)gl->font_last_height / (gl->vp_height * scale_factor) + ly;
font_vertex[0] = lx;
font_vertex[1] = ly;

View File

@ -164,10 +164,11 @@ static void set_defaults(void)
g_settings.video.crop_overscan = crop_overscan;
g_settings.video.aspect_ratio = -1.0f; // Automatic
g_settings.video.shader_type = SSNES_SHADER_AUTO;
g_settings.video.font_enable = font_enable;
#ifdef HAVE_FREETYPE
g_settings.video.font_enable = font_enable;
g_settings.video.font_size = font_size;
g_settings.video.font_scale = font_scale;
g_settings.video.msg_pos_x = message_pos_offset_x;
g_settings.video.msg_pos_y = message_pos_offset_y;
@ -366,6 +367,7 @@ static void parse_config_file(void)
CONFIG_GET_STRING(video.font_path, "video_font_path");
CONFIG_GET_INT(video.font_size, "video_font_size");
CONFIG_GET_BOOL(video.font_enable, "video_font_enable");
CONFIG_GET_BOOL(video.font_scale, "video_font_scale");
CONFIG_GET_DOUBLE(video.msg_pos_x, "video_message_pos_x");
CONFIG_GET_DOUBLE(video.msg_pos_y, "video_message_pos_y");

View File

@ -89,6 +89,9 @@
# Size of the TTF font rendered.
# video_font_size = 48
# Attempt to scale the font to fit better for multiple window sizes.
# video_font_scale = true
# Enable usage of OSD messages.
# video_font_enable = true