diff --git a/src/drivers/graphics/renderer.c b/src/drivers/graphics/renderer.c index 32840af..e335aaf 100644 --- a/src/drivers/graphics/renderer.c +++ b/src/drivers/graphics/renderer.c @@ -99,6 +99,15 @@ position_T graphics_buffer_draw_string(graphics_buffer_T* graphics_buffer, uint3 position_T pos = (position_T){x, y}; uint64_t strlen = string_length(string); for (int i = 0; i < strlen; i++) { + if (pos.x + g_renderer.font.width >= graphics_buffer->width) { + pos.x = 0; + pos.y += g_renderer.font.height; + } + if (pos.y + g_renderer.font.height >= graphics_buffer->height) { + pos.y -= g_renderer.font.height; + graphics_buffer_shift_up(graphics_buffer, g_renderer.font.height); + } + switch (string[i]) { case '\n': { pos.x = 0; @@ -122,14 +131,6 @@ position_T graphics_buffer_draw_string(graphics_buffer_T* graphics_buffer, uint3 } default: { - if (pos.x + g_renderer.font.width >= graphics_buffer->width) { - pos.x = 0; - pos.y += g_renderer.font.height; - } - if (pos.y + g_renderer.font.height >= graphics_buffer->height) { - pos.y -= g_renderer.font.height; - graphics_buffer_shift_up(graphics_buffer, g_renderer.font.height); - } graphics_buffer_draw_char(graphics_buffer, pos.x, pos.y, color, string[i]); pos.x += g_renderer.font.width; break;