From b981909c9c2667d2af013c164a4bb2483f0cbb98 Mon Sep 17 00:00:00 2001 From: M4xw Date: Sat, 21 Jul 2018 21:06:28 +0200 Subject: [PATCH 1/3] Meaningful error log --- gfx/drivers_font/switch_font.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gfx/drivers_font/switch_font.c b/gfx/drivers_font/switch_font.c index 82ff2a7867..d3c9aa4b93 100644 --- a/gfx/drivers_font/switch_font.c +++ b/gfx/drivers_font/switch_font.c @@ -177,11 +177,11 @@ static void switch_font_render_line( // Safeguard if ((glyphx + width * FONT_SCALE) > 1280) { - printf("glpyhx violated %i\n", (glyphx + width * FONT_SCALE)); + printf("glpyhx %i (x: %i, off_x: %i, delta_x: %i), violated calc: %i, width: %i\n", glyphx,x, off_x, delta_x, (glyphx + width * FONT_SCALE), width); } else if ((glyphy + height * FONT_SCALE) > 720) { - printf("glyphy violated %i\n", (glyphy + height * FONT_SCALE)); + printf("glyphy %i (y: %i, off_y: %i, delta_y: %i) , violated %i, glyphy: %i, heigth: %i\n",glyphy,y, off_y, delta_y, (glyphy + height * FONT_SCALE), glyphy, height); } else { -- GitLab From e133e6a45d6efe1a3996aa0a64c0017367ac4308 Mon Sep 17 00:00:00 2001 From: M4xw Date: Sat, 21 Jul 2018 21:12:32 +0200 Subject: [PATCH 2/3] Debug stuff --- gfx/drivers_font/switch_font.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gfx/drivers_font/switch_font.c b/gfx/drivers_font/switch_font.c index d3c9aa4b93..070282229f 100644 --- a/gfx/drivers_font/switch_font.c +++ b/gfx/drivers_font/switch_font.c @@ -175,15 +175,19 @@ static void switch_font_render_line( int glyphy = y + off_y + delta_y * FONT_SCALE - FONT_SCALE * 2; // Safeguard + bool x_ok = true, y_ok = true; if ((glyphx + width * FONT_SCALE) > 1280) { - printf("glpyhx %i (x: %i, off_x: %i, delta_x: %i), violated calc: %i, width: %i\n", glyphx,x, off_x, delta_x, (glyphx + width * FONT_SCALE), width); + x_ok = false; + printf("glpyhx %i (x: %i, off_x: %i, delta_x: %i), violated calc: %i, width: %i\n", glyphx, x, off_x, delta_x, (glyphx + width * FONT_SCALE), width); } - else if ((glyphy + height * FONT_SCALE) > 720) + if ((glyphy + height * FONT_SCALE) > 720) { - printf("glyphy %i (y: %i, off_y: %i, delta_y: %i) , violated %i, glyphy: %i, heigth: %i\n",glyphy,y, off_y, delta_y, (glyphy + height * FONT_SCALE), glyphy, height); + y_ok = false; + printf("glyphy %i (y: %i, off_y: %i, delta_y: %i) , violated %i, glyphy: %i, heigth: %i\n", glyphy, y, off_y, delta_y, (glyphy + height * FONT_SCALE), glyphy, height); } - else + + if (x_ok && y_ok) { gfx_slow_swizzling_blit(out_buffer, glyph_buffer, width * FONT_SCALE, height * FONT_SCALE, glyphx, glyphy, true); } -- GitLab From 0a4ce5d2e8077bb5b11b53228408bca704b6bfd1 Mon Sep 17 00:00:00 2001 From: M4xw Date: Sat, 21 Jul 2018 23:05:19 +0200 Subject: [PATCH 3/3] Add max length, undo safeguard --- gfx/drivers_font/switch_font.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/gfx/drivers_font/switch_font.c b/gfx/drivers_font/switch_font.c index 070282229f..e0e377690f 100644 --- a/gfx/drivers_font/switch_font.c +++ b/gfx/drivers_font/switch_font.c @@ -174,7 +174,8 @@ static void switch_font_render_line( int glyphx = x + off_x + delta_x * FONT_SCALE + FONT_SCALE * 2; int glyphy = y + off_y + delta_y * FONT_SCALE - FONT_SCALE * 2; - // Safeguard + // Gonna try to catch it prior +#if 0 bool x_ok = true, y_ok = true; if ((glyphx + width * FONT_SCALE) > 1280) { @@ -186,11 +187,11 @@ static void switch_font_render_line( y_ok = false; printf("glyphy %i (y: %i, off_y: %i, delta_y: %i) , violated %i, glyphy: %i, heigth: %i\n", glyphy, y, off_y, delta_y, (glyphy + height * FONT_SCALE), glyphy, height); } - - if (x_ok && y_ok) - { - gfx_slow_swizzling_blit(out_buffer, glyph_buffer, width * FONT_SCALE, height * FONT_SCALE, glyphx, glyphy, true); - } +#endif + //if (x_ok && y_ok) + //{ + gfx_slow_swizzling_blit(out_buffer, glyph_buffer, width * FONT_SCALE, height * FONT_SCALE, glyphx, glyphy, true); + //} free(glyph_buffer); @@ -219,7 +220,6 @@ static void switch_font_render_message( scale, color, pos_x, pos_y, text_align); return; } - line_height = scale / font->font_driver->get_line_height(font->font_data); for (;;) @@ -262,7 +262,7 @@ static void switch_font_render_msg( unsigned width = video_info->width; unsigned height = video_info->height; - if (!font || !msg || !*msg) + if (!font || !msg || msg && !*msg) return; if (params) @@ -303,6 +303,9 @@ static void switch_font_render_msg( } max_glyphs = strlen(msg); + // Garbage data on threading :shrug: + if (max_glyphs > 140) + return; // This is max length on 5 avg width /*if (drop_x || drop_y) max_glyphs *= 2; -- GitLab