caca: fix font alignment

This commit is contained in:
Brad Parker 2017-01-21 15:39:29 -05:00
parent a7b26d8913
commit 0290f4713c
2 changed files with 25 additions and 7 deletions

View File

@ -137,7 +137,7 @@ static bool caca_gfx_frame(void *data, const void *frame,
if (!caca_cv)
return true;
if (caca_menu_frame)
if (caca_menu_frame && menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL))
frame_to_copy = caca_menu_frame;
width = caca_get_canvas_width(caca_cv);
@ -149,6 +149,9 @@ static bool caca_gfx_frame(void *data, const void *frame,
(frame_width < width && frame_height < height))
draw = false;
if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL))
draw = false;
caca_clear_canvas(caca_cv);
#ifdef HAVE_MENU

View File

@ -77,9 +77,10 @@ static void caca_render_msg(video_frame_info_t *video_info,
void *data, const char *msg,
const void *userdata)
{
float x, y;
float x, y, scale;
unsigned width, height;
unsigned newX, newY;
unsigned align;
caca_raster_t *font = (caca_raster_t*)data;
const struct font_params *params = (const struct font_params*)userdata;
@ -90,11 +91,15 @@ static void caca_render_msg(video_frame_info_t *video_info,
{
x = params->x;
y = params->y;
scale = params->scale;
align = params->text_align;
}
else
{
x = video_info->font_msg_pos_x;
y = video_info->font_msg_pos_y;
scale = 1.0f;
align = TEXT_ALIGN_LEFT;
}
if (!font->caca || !font->caca->caca_cv || !font->caca->caca_display ||
@ -103,12 +108,22 @@ static void caca_render_msg(video_frame_info_t *video_info,
width = caca_get_canvas_width(*font->caca->caca_cv);
height = caca_get_canvas_height(*font->caca->caca_cv);
newY = height - (y * height * scale);
newX = x * width;
newY = height - (y * height);
if (strlen(msg) + newX > width)
newX -= strlen(msg) + newX - width;
switch (align)
{
case TEXT_ALIGN_LEFT:
newX = x * width * scale;
break;
case TEXT_ALIGN_RIGHT:
newX = (x * width * scale) - strlen(msg);
break;
case TEXT_ALIGN_CENTER:
newX = (x * width * scale) - (strlen(msg) / 2);
break;
default:
break;
}
caca_put_str(*font->caca->caca_cv, newX, newY, msg);