From 4d98e6e6a3c9f149036001017b88070239f083bb Mon Sep 17 00:00:00 2001 From: Maic Siemering Date: Tue, 27 May 2025 13:38:52 +0200 Subject: [PATCH 1/2] fix label cut off text caused by multiline and kerning --- arcade/gui/widgets/text.py | 7 ++++--- tests/unit/gui/test_uilabel.py | 5 ++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/arcade/gui/widgets/text.py b/arcade/gui/widgets/text.py index 91353eeb43..fd8d877d78 100644 --- a/arcade/gui/widgets/text.py +++ b/arcade/gui/widgets/text.py @@ -126,8 +126,8 @@ def __init__( self._strong_background = True if adaptive_multiline: - # +1 is required to prevent line wrap - width = self._label.content_width + 1 + # +1 is required to prevent line wrap, +1 is required to prevent issues with kerning + width = self._label.content_width + 2 super().__init__( x=x, @@ -242,7 +242,8 @@ def _update_label(self): def _update_size_hint_min(self): """Update the minimum size hint based on the label content size.""" - min_width = self._label.content_width + 1 # +1 required to prevent line wrap + # +1 is required to prevent line wrap, +1 is required to prevent issues with kerning + min_width = self._label.content_width + 2 min_width += self._padding_left + self._padding_right + 2 * self._border_width min_height = self._label.content_height diff --git a/tests/unit/gui/test_uilabel.py b/tests/unit/gui/test_uilabel.py index ae443873f4..a78828d166 100644 --- a/tests/unit/gui/test_uilabel.py +++ b/tests/unit/gui/test_uilabel.py @@ -1,6 +1,5 @@ from unittest.mock import Mock -import pytest from pyglet.math import Vec2 from arcade.gui import UILabel @@ -192,7 +191,7 @@ def test_integration_with_layout_fit_to_content(ui): ui.execute_layout() # auto size should fit the text - assert label.rect.width == 44 + assert label.rect.width == 45 assert label.rect.height == 12 # even when text changed @@ -221,7 +220,7 @@ def test_fit_content_overrides_width(ui): label.fit_content() - assert label.rect.width == 44 + assert label.rect.width == 45 assert label.rect.height == 12 From db2c0e692481d9240d9e3c12e7e304064a3539aa Mon Sep 17 00:00:00 2001 From: Maic Siemering Date: Tue, 27 May 2025 14:13:29 +0200 Subject: [PATCH 2/2] add changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1759f78704..61fff6f8db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ Arcade [PyPi Release History](https://pypi.org/project/arcade/#history) page. - Fixed an issue causing a crash when closing the window - Added `Window.close` (bool) attribute indicating if the window is closed +- GUI + - Fix `UILabel` with enabled multiline sometimes cut off text ## Version 3.2