Skip to content

Commit bbc0ea9

Browse files
author
Margaret Matocha
committed
Updated to regenerate all character tileGrids upon text change
1 parent b311402 commit bbc0ea9

File tree

1 file changed

+1
-26
lines changed

1 file changed

+1
-26
lines changed

adafruit_display_text/label.py

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ def _update_text(
232232
i = 1
233233
else:
234234
i = 0
235-
old_c = 0
236235
y_offset = int(
237236
(
238237
self._font.get_glyph(ord("M")).height
@@ -257,11 +256,7 @@ def _update_text(
257256
bottom = max(bottom, y - glyph.dy + y_offset)
258257
position_y = y - glyph.height - glyph.dy + y_offset
259258
position_x = x + glyph.dx
260-
if (
261-
not self._text
262-
or old_c >= len(self._text)
263-
or character != self._text[old_c]
264-
) and (glyph.width > 0 and glyph.height > 0):
259+
if glyph.width > 0 and glyph.height > 0:
265260
try:
266261
# pylint: disable=unexpected-keyword-arg
267262
face = displayio.TileGrid(
@@ -286,28 +281,8 @@ def _update_text(
286281
self[i] = face
287282
else:
288283
self.append(face)
289-
elif self._text and character == self._text[old_c]:
290-
291-
try:
292-
self[i].position = (position_x, position_y)
293-
except AttributeError:
294-
self[i].x = position_x
295-
self[i].y = position_y
296-
297284
x += glyph.shift_x
298-
# TODO skip this for control sequences or non-printables.
299285
i += 1
300-
old_c += 1
301-
# skip all non-printables in the old string
302-
while (
303-
self._text
304-
and old_c < len(self._text)
305-
and (
306-
self._text[old_c] == "\n"
307-
or not self._font.get_glyph(ord(self._text[old_c]))
308-
)
309-
):
310-
old_c += 1
311286
# Remove the rest
312287
while len(self) > i:
313288
self.pop()

0 commit comments

Comments
 (0)