From 9e6f24187ebe2577fde7c7a971a8cc408f4aeaac Mon Sep 17 00:00:00 2001 From: cflip Date: Wed, 11 Jan 2023 11:17:38 -0700 Subject: Don't try to draw newline characters --- window.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/window.c b/window.c index 7f29abe..315e75e 100644 --- a/window.c +++ b/window.c @@ -97,11 +97,17 @@ static void draw_font_text(struct append_buffer *buffer) for (int i = 0; i < buffer->length; i++) { const char letter = buffer->buffer[i]; + if (letter == ' ') { dstrect.x += font.width; continue; } + if (letter == '\n') { + dstrect.x = 0; + dstrect.y += font.height; + continue; + } int glyph_index = letter; if (font.unicode_desc != NULL) { @@ -117,12 +123,7 @@ static void draw_font_text(struct append_buffer *buffer) srcrect.h = font.height; SDL_RenderCopy(renderer, font_texture, &srcrect, &dstrect); - if (letter == '\n') { - dstrect.x = 0; - dstrect.y += font.height; - } else { - dstrect.x += font.width; - } + dstrect.x += font.width; } } -- cgit v1.2.3