shithub: m8c

Download patch

ref: 3b59f68a2a9a66129567872251dee58b6cbbf131
parent: 514e71a670e372703dc8768ed678ae1e623d7767
author: Jonne Kokkonen <jonne.kokkonen@gmail.com>
date: Mon Mar 3 10:38:25 EST 2025

#180 backport sdl3 font whitespace fix

--- a/src/inprint2.c
+++ b/src/inprint2.c
@@ -95,7 +95,9 @@
     dst = selected_renderer;
 
   for (; *str; str++) {
-    int id = (int)*str - font_offset;
+    const int ascii_code = (int)*str;
+    int id = ascii_code - font_offset;
+
 #if (CHARACTERS_PER_COLUMN != 1)
     int row = id / CHARACTERS_PER_ROW;
     int col = id % CHARACTERS_PER_ROW;
@@ -125,8 +127,10 @@
 
       SDL_RenderFillRect(dst, &bg_rect);
     }
-    SDL_RenderCopy(dst, selected_font, &s_rect, &d_rect);
-    d_rect.x += selected_inline_font->glyph_x + 1;
+    // Do not try to render a whitespace character because the font doesn't have one
+    if (ascii_code != 32) {
+      SDL_RenderCopy(dst, selected_font, &s_rect, &d_rect);
+    }    d_rect.x += selected_inline_font->glyph_x + 1;
   }
 }
 SDL_Texture *get_inline_font(void) { return selected_font; }
--