added support for narrow font if game panel text too large
authorHolger Schemel <holger.schemel@virtion.de>
Sat, 4 Jan 2025 16:25:03 +0000 (17:25 +0100)
committerHolger Schemel <holger.schemel@virtion.de>
Sat, 4 Jan 2025 16:25:07 +0000 (17:25 +0100)
If player name, level set name, level name or level author to be drawn
on game panel is larger than a specified size (using ".chars" option)
or larger than the game panel width, an alternative (less wide) font
(using ".font_narrow" option) will be used.

src/conf_gfx.c
src/game.c

index 034873ae8da893026db6490a34a094df668f6cfc..a1f56f9b2937a404c0f403463ccb7ab6dce37880 100644 (file)
@@ -11012,6 +11012,7 @@ struct ConfigInfo image_config[] =
   { "game.panel.player_name.valign",                   "top"                           },
   { "game.panel.player_name.chars",                    "-1"                            },
   { "game.panel.player_name.font",                     "font.text_2"                   },
+  { "game.panel.player_name.font_narrow",              "font.text_1"                   },
   { "game.panel.player_name.draw_masked",              "true"                          },
   { "game.panel.player_name.draw_order",               "0"                             },
   { "game.panel.player_name.class",                    "none"                          },
@@ -11023,6 +11024,7 @@ struct ConfigInfo image_config[] =
   { "game.panel.levelset_name.valign",                 "top"                           },
   { "game.panel.levelset_name.chars",                  "-1"                            },
   { "game.panel.levelset_name.font",                   "font.text_2"                   },
+  { "game.panel.levelset_name.font_narrow",            "font.text_1"                   },
   { "game.panel.levelset_name.draw_masked",            "true"                          },
   { "game.panel.levelset_name.draw_order",             "0"                             },
   { "game.panel.levelset_name.class",                  "none"                          },
@@ -11034,6 +11036,7 @@ struct ConfigInfo image_config[] =
   { "game.panel.level_name.valign",                    "top"                           },
   { "game.panel.level_name.chars",                     "-1"                            },
   { "game.panel.level_name.font",                      "font.text_2"                   },
+  { "game.panel.level_name.font_narrow",               "font.text_1"                   },
   { "game.panel.level_name.draw_masked",               "true"                          },
   { "game.panel.level_name.draw_order",                        "0"                             },
   { "game.panel.level_name.class",                     "none"                          },
@@ -11045,6 +11048,7 @@ struct ConfigInfo image_config[] =
   { "game.panel.level_author.valign",                  "top"                           },
   { "game.panel.level_author.chars",                   "-1"                            },
   { "game.panel.level_author.font",                    "font.text_2"                   },
+  { "game.panel.level_author.font_narrow",             "font.text_1"                   },
   { "game.panel.level_author.draw_masked",             "true"                          },
   { "game.panel.level_author.draw_order",              "0"                             },
   { "game.panel.level_author.class",                   "none"                          },
index 66935e7f948dec39f32617b7102bbbe721d26ece..27bc34bdeb66dc170565e54c61dad3f7a419a357 100644 (file)
@@ -2973,6 +2973,15 @@ static void DisplayGameControlValues(void)
 
        font = (active ? font2 : font1);
       }
+      else if (nr == GAME_PANEL_PLAYER_NAME ||
+               nr == GAME_PANEL_LEVELSET_NAME ||
+               nr == GAME_PANEL_LEVEL_NAME ||
+               nr == GAME_PANEL_LEVEL_AUTHOR)
+      {
+        // use alternative (narrow) font if text larger than specified size or game panel width
+        if ((size > 0 && strlen(s) > size) || strlen(s) * getFontWidth(font) > DXSIZE)
+          font = pos->font_alt;
+      }
 
       if (s != NULL)
       {