added fallback to narrow font on word length for envelope request dialogs
authorHolger Schemel <info@artsoft.org>
Tue, 5 Dec 2023 17:14:33 +0000 (18:14 +0100)
committerHolger Schemel <info@artsoft.org>
Tue, 5 Dec 2023 17:14:41 +0000 (18:14 +0100)
src/conf_gfx.c
src/main.c
src/main.h
src/tools.c

index 891e1500460568f5d42cc8a64b62e0e207dbe305..7b9d243ed52ba6b8169815741bae91460e09c35f 100644 (file)
@@ -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"                     },
index bb8e1f0d7b5cbdec63e273b9ff0eb1424d6530f9..a1ba5c7c5cc6069b92d5ec07e8bb689848182b70 100644 (file)
@@ -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"      },
index 228ca5a63b0d6b92f462b95ba6259921e22ae57f..08cb1e5c394df355190d259d6fe49d2221e1a055 100644 (file)
@@ -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,
index e56516a016ef5cd04e40b08d3a55ae966e9fc968..a3aa3c34a9cbe12bf06beeb3c58395e6ae420019 100644 (file)
@@ -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;