From 32ceded7724ca14e43a10cc88d0a9a591220b37e Mon Sep 17 00:00:00 2001 From: MysterD Date: Fri, 28 Jan 2022 00:00:25 -0800 Subject: [PATCH] Prevent rendering of unimplemented characters --- src/pc/djui/djui_font.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pc/djui/djui_font.c b/src/pc/djui/djui_font.c index 96f408ddf..cbeab3b0b 100644 --- a/src/pc/djui/djui_font.c +++ b/src/pc/djui/djui_font.c @@ -37,6 +37,8 @@ static const Gfx djui_font_normal_text_settings[] = { static void djui_font_normal_render_char(char c) { extern const u8* const font_normal_chars[]; + // replace undisplayable characters + if (c < ' ' || (u8)c > ('~' + 1)) { c = '?'; } void* fontChar = (void*)font_normal_chars[c - '!']; if (fontChar == NULL) { fontChar = (void*)font_normal_chars[94]; } @@ -68,6 +70,8 @@ static const struct DjuiFont sDjuiFontNormal = { static void djui_font_title_render_char(char c) { extern const u8* const font_title_chars[]; + // replace undisplayable characters + if (c < ' ' || (u8)c > ('~' + 1)) { c = '?'; } djui_gfx_render_texture(font_title_chars[c - '!'], 64, 64, 32); }