Skip to content

Updated to regenerate all character tileGrids upon text change #66

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 1 addition & 26 deletions adafruit_display_text/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ def _update_text(
i = 1
else:
i = 0
old_c = 0
y_offset = int(
(
self._font.get_glyph(ord("M")).height
Expand All @@ -257,11 +256,7 @@ def _update_text(
bottom = max(bottom, y - glyph.dy + y_offset)
position_y = y - glyph.height - glyph.dy + y_offset
position_x = x + glyph.dx
if (
not self._text
or old_c >= len(self._text)
or character != self._text[old_c]
) and (glyph.width > 0 and glyph.height > 0):
if glyph.width > 0 and glyph.height > 0:
try:
# pylint: disable=unexpected-keyword-arg
face = displayio.TileGrid(
Expand All @@ -286,28 +281,8 @@ def _update_text(
self[i] = face
else:
self.append(face)
elif self._text and character == self._text[old_c]:

try:
self[i].position = (position_x, position_y)
except AttributeError:
self[i].x = position_x
self[i].y = position_y

x += glyph.shift_x
# TODO skip this for control sequences or non-printables.
i += 1
old_c += 1
# skip all non-printables in the old string
while (
self._text
and old_c < len(self._text)
and (
self._text[old_c] == "\n"
or not self._font.get_glyph(ord(self._text[old_c]))
)
):
old_c += 1
# Remove the rest
while len(self) > i:
self.pop()
Expand Down