Skip to content

Commit 69cc1bf

Browse files
author
Margaret Matocha
committed
updated font and text setters, so that the anchored_position is properly set after a font or text change
1 parent 02f26d9 commit 69cc1bf

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

adafruit_display_text/label.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,9 @@ def text(self):
227227

228228
@text.setter
229229
def text(self, new_text):
230+
current_anchored_position = self.anchored_position
230231
self._update_text(str(new_text))
232+
self.anchored_position = current_anchored_position
231233

232234
@property
233235
def font(self):
@@ -237,11 +239,13 @@ def font(self):
237239
@font.setter
238240
def font(self, new_font):
239241
old_text = self._text
242+
current_anchored_position = self.anchored_position
240243
self._text = ""
241244
self._font = new_font
242245
bounds = self._font.get_bounding_box()
243246
self.height = bounds[1]
244247
self._update_text(str(old_text))
248+
self.anchored_position = current_anchored_position
245249

246250
@property
247251
def anchor_point(self):

0 commit comments

Comments
 (0)