From 7ec78e94db9bc2c10b08ee92205d418a88d25362 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Mon, 16 Jun 2025 18:30:47 +0100 Subject: [PATCH] Fix: Don't include height of blank text in frame and inset widgets. --- src/widget.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/widget.cpp b/src/widget.cpp index cea84a481d..a9d68d2669 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -2264,9 +2264,11 @@ void NWidgetBackground::SetupSmallestSize(Window *w) if (w != nullptr) { // A non-nullptr window pointer acts as switch to turn dynamic widget size on. if (this->type == WWT_FRAME || this->type == WWT_INSET) { std::string text = GetStringForWidget(w, this); - Dimension background = GetStringBoundingBox(text, this->text_size); - background.width += (this->type == WWT_FRAME) ? (WidgetDimensions::scaled.frametext.Horizontal()) : (WidgetDimensions::scaled.inset.Horizontal()); - d = maxdim(d, background); + if (!text.empty()) { + Dimension background = GetStringBoundingBox(text, this->text_size); + background.width += (this->type == WWT_FRAME) ? (WidgetDimensions::scaled.frametext.Horizontal()) : (WidgetDimensions::scaled.inset.Horizontal()); + d = maxdim(d, background); + } } if (this->index >= 0) { Dimension padding;