From a42320dc0f3af61bee63a8d81508e6ff5b44c41b Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Tue, 5 Dec 2023 18:14:33 +0100 Subject: [PATCH] added fallback to narrow font on word length for envelope request dialogs --- src/conf_gfx.c | 2 ++ src/main.c | 1 + src/main.h | 1 + src/tools.c | 7 +++++++ 4 files changed, 11 insertions(+) diff --git a/src/conf_gfx.c b/src/conf_gfx.c index 891e1500..7b9d243e 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -6858,6 +6858,8 @@ struct ConfigInfo image_config[] = { "font.request.y", "210" }, { "font.request.width", "14" }, { "font.request.height", "14" }, + { "font.request_narrow", UNDEFINED_FILENAME }, + { "font.request_narrow.clone_from", "font.text_1.DOOR" }, { "font.input_1", "RocksFontSmall.png" }, { "font.input_1.x", "0" }, diff --git a/src/main.c b/src/main.c index bb8e1f0d..a1ba5c7c 100644 --- a/src/main.c +++ b/src/main.c @@ -7644,6 +7644,7 @@ struct FontInfo font_info[NUM_FONTS + 1] = { "font.envelope_2" }, { "font.envelope_3" }, { "font.envelope_4" }, + { "font.request_narrow" }, { "font.request" }, { "font.input_1.active" }, { "font.input_2.active" }, diff --git a/src/main.h b/src/main.h index 228ca5a6..08cb1e5c 100644 --- a/src/main.h +++ b/src/main.h @@ -2553,6 +2553,7 @@ enum FONT_ENVELOPE_2, FONT_ENVELOPE_3, FONT_ENVELOPE_4, + FONT_REQUEST_NARROW, FONT_REQUEST, FONT_INPUT_1_ACTIVE, FONT_INPUT_2_ACTIVE, diff --git a/src/tools.c b/src/tools.c index e56516a0..a3aa3c34 100644 --- a/src/tools.c +++ b/src/tools.c @@ -3176,6 +3176,13 @@ static void DrawEnvelopeRequestText(int sx, int sy, char *text) { char *src_text_ptr, *dst_text_ptr; + if (maxWordLengthInRequestString(text) > line_length) + { + font_nr = FONT_REQUEST_NARROW; + font_width = getFontWidth(font_nr); + line_length = max_text_width / font_width; + } + text_door_style = checked_malloc(2 * strlen(text) + 1); src_text_ptr = text; -- 2.34.1