From 627563b79170e514f2fdb6561985f4667f3343e0 Mon Sep 17 00:00:00 2001 From: James Carr Date: Mon, 8 Feb 2021 09:43:36 +0000 Subject: [PATCH 1/2] This is a fix for adafruit/Adafruit_CircuitPython_Display_Text#113 . It keeps the scale of this outer Label at 1 and passes any scale setting through to the local_group inside as described in the comments already in the __init__ method. --- adafruit_display_text/label.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/adafruit_display_text/label.py b/adafruit_display_text/label.py index 486a14f..1d83266 100755 --- a/adafruit_display_text/label.py +++ b/adafruit_display_text/label.py @@ -130,8 +130,6 @@ def __init__( self._padding_left = padding_left self._padding_right = padding_right - self._scale = scale - if text is not None: self._update_text(str(text)) if (anchored_position is not None) and (anchor_point is not None): @@ -389,12 +387,11 @@ def text(self, new_text): @property def scale(self): """Set the scaling of the label, in integer values""" - return self._scale + return self.local_group.scale @scale.setter def scale(self, new_scale): current_anchored_position = self.anchored_position - self._scale = new_scale self.local_group.scale = new_scale self.anchored_position = current_anchored_position From 9871e1852a817f23c21e6b5506cfca1db49e921b Mon Sep 17 00:00:00 2001 From: James Carr Date: Tue, 9 Feb 2021 14:08:54 +0000 Subject: [PATCH 2/2] Change the self._scale calls to self.scale in the anchored_position getter and setter. --- adafruit_display_text/label.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/adafruit_display_text/label.py b/adafruit_display_text/label.py index 1d83266..f87dc17 100755 --- a/adafruit_display_text/label.py +++ b/adafruit_display_text/label.py @@ -435,13 +435,13 @@ def anchored_position(self): return ( int( self.x - + (self._boundingbox[0] * self._scale) - + round(self._anchor_point[0] * self._boundingbox[2] * self._scale) + + (self._boundingbox[0] * self.scale) + + round(self._anchor_point[0] * self._boundingbox[2] * self.scale) ), int( self.y - + (self._boundingbox[1] * self._scale) - + round(self._anchor_point[1] * self._boundingbox[3] * self._scale) + + (self._boundingbox[1] * self.scale) + + round(self._anchor_point[1] * self._boundingbox[3] * self.scale) ), ) @@ -451,11 +451,11 @@ def anchored_position(self, new_position): return # Note: anchor_point must be set before setting anchored_position self.x = int( new_position[0] - - (self._boundingbox[0] * self._scale) - - round(self._anchor_point[0] * (self._boundingbox[2] * self._scale)) + - (self._boundingbox[0] * self.scale) + - round(self._anchor_point[0] * (self._boundingbox[2] * self.scale)) ) self.y = int( new_position[1] - - (self._boundingbox[1] * self._scale) - - round(self._anchor_point[1] * self._boundingbox[3] * self._scale) + - (self._boundingbox[1] * self.scale) + - round(self._anchor_point[1] * self._boundingbox[3] * self.scale) )