From 47050d911d9d02de93608345dd510b60a70f5f51 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sat, 4 Jan 2025 17:25:03 +0100 Subject: [PATCH] added support for narrow font if game panel text too large 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 | 4 ++++ src/game.c | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/src/conf_gfx.c b/src/conf_gfx.c index 034873ae..a1f56f9b 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -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" }, diff --git a/src/game.c b/src/game.c index 66935e7f..27bc34bd 100644 --- a/src/game.c +++ b/src/game.c @@ -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) { -- 2.34.1