Skip to content

Commit a001c02

Browse files
Refactor width & height
1 parent d557cf8 commit a001c02

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

adafruit_display_text/label.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ def __init__(self, font, **kwargs) -> None:
8787

8888
text = self._replace_tabs(self._text)
8989

90-
self.width = len(text)
91-
self.height = self._font.get_bounding_box()[1]
90+
self._width = len(text)
91+
self._height = self._font.get_bounding_box()[1]
9292

9393
# Create the two-color text palette
9494
self._palette[0] = 0
@@ -119,7 +119,7 @@ def _create_background_box(self, lines: int, y_offset: int) -> TileGrid:
119119
x_box_offset = -self._padding_bottom
120120
box_width = (
121121
(ascent + descent)
122-
+ int((lines - 1) * self.width * self._line_spacing)
122+
+ int((lines - 1) * self._width * self._line_spacing)
123123
+ self._padding_left
124124
+ self._padding_right
125125
)
@@ -130,7 +130,7 @@ def _create_background_box(self, lines: int, y_offset: int) -> TileGrid:
130130
x_box_offset = -self._padding_left
131131
box_height = (
132132
(ascent + descent)
133-
+ int((lines - 1) * self.height * self._line_spacing)
133+
+ int((lines - 1) * self._height * self._line_spacing)
134134
+ self._padding_top
135135
+ self._padding_bottom
136136
)
@@ -248,7 +248,7 @@ def _update_text(self, new_text: str) -> None:
248248

249249
for character in new_text:
250250
if character == "\n":
251-
y += int(self.height * self._line_spacing)
251+
y += int(self._height * self._line_spacing)
252252
x = 0
253253
continue
254254
glyph = self._font.get_glyph(ord(character))
@@ -402,7 +402,7 @@ def _set_font(self, new_font) -> None:
402402
current_anchored_position = self.anchored_position
403403
self._text = ""
404404
self._font = new_font
405-
self.height = self._font.get_bounding_box()[1]
405+
self._height = self._font.get_bounding_box()[1]
406406
self._update_text(str(old_text))
407407
self.anchored_position = current_anchored_position
408408

0 commit comments

Comments
 (0)