Skip to content

Commit 1e388fc

Browse files
committed
basic multiline
1 parent bd7ae0c commit 1e388fc

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

adafruit_display_text/text_area.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,14 @@ def __init__(self, font, *, text=None, width=None, color=0x0, height=1):
7575

7676
def _update_text(self, new_text):
7777
x = 0
78+
y = 0
7879
i = 0
7980
first_different = self._text is not None
8081
for c in new_text:
82+
if chr(ord(c)) == '\n':
83+
y += int(self.height * 1.5)
84+
x = 0
85+
continue
8186
glyph = self.font.get_glyph(ord(c))
8287
if not glyph:
8388
continue
@@ -90,7 +95,7 @@ def _update_text(self, new_text):
9095
first_different = False
9196
if not first_different:
9297
face = displayio.Sprite(glyph["bitmap"], pixel_shader=self.p,
93-
position=(self._x + x, self._y + self.height - glyph["bounds"][1] - glyph["bounds"][3]))
98+
position=(self._x + x, self._y + y + self.height - glyph["bounds"][1] - glyph["bounds"][3]))
9499
self.group.append(face)
95100
self.sprites[i] = face
96101
x += glyph["shift"][0]

0 commit comments

Comments
 (0)