From 9cf2f27011bad2e141c1366378d75b6e781fa2bd Mon Sep 17 00:00:00 2001 From: snkYmkrct Date: Sat, 10 Sep 2022 15:23:57 +0200 Subject: [PATCH] Fix for bitmap_label losing direction bug 169 --- adafruit_display_text/bitmap_label.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/adafruit_display_text/bitmap_label.py b/adafruit_display_text/bitmap_label.py index 28a037c..a37f940 100755 --- a/adafruit_display_text/bitmap_label.py +++ b/adafruit_display_text/bitmap_label.py @@ -547,9 +547,12 @@ def _set_background_color(self, new_color: Optional[int]): self._palette.make_transparent(0) def _set_label_direction(self, new_label_direction: str) -> None: - self._prev_label_direction = self._label_direction - self._label_direction = new_label_direction - self._reset_text(text=str(self._text)) # Force a recalculation + # Only make changes if new direction is different + # to prevent errors in the _reset_text() direction checks + if self._label_direction != new_label_direction: + self._prev_label_direction = self._label_direction + self._label_direction = new_label_direction + self._reset_text(text=str(self._text)) # Force a recalculation def _get_valid_label_directions(self) -> Tuple[str, ...]: return "LTR", "RTL", "UPD", "UPR", "DWR"