Skip to content

Commit b598e15

Browse files
committed
fix y position shifting when text changes
1 parent ff4be27 commit b598e15

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

adafruit_display_text/label.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,11 @@ def anchored_position(self):
390390
+ round(self._anchor_point[0] * self._boundingbox[2] * self._scale)
391391
),
392392
int(
393-
self.y
394-
+ (self._anchor_point[1] * self._boundingbox[3] * self._scale)
395-
- round((self._boundingbox[3] * self._scale) / 2.0)
393+
round(
394+
self.y
395+
+ (self._anchor_point[1] * self._boundingbox[3] * self._scale)
396+
- ((self._boundingbox[3] * self._scale) / 2.0)
397+
)
396398
),
397399
)
398400

@@ -405,9 +407,11 @@ def anchored_position(self, new_position):
405407
- round(self._anchor_point[0] * (self._boundingbox[2] * self._scale))
406408
)
407409
new_y = int(
408-
new_position[1]
409-
- (self._anchor_point[1] * self._boundingbox[3] * self._scale)
410-
+ round((self._boundingbox[3] * self._scale) / 2.0)
410+
round(
411+
new_position[1]
412+
- (self._anchor_point[1] * self._boundingbox[3] * self._scale)
413+
+ ((self._boundingbox[3] * self._scale) / 2.0)
414+
)
411415
)
412416
self.x = new_x
413417
self.y = new_y

0 commit comments

Comments
 (0)