Skip to content

Commit 784a80b

Browse files
authored
Merge pull request #184 from Neradoc/fix-multiple-lines-in-bitmaplabel
Fix multiple lines in bitmap label causing an error
2 parents 966c3ad + 7e79bf3 commit 784a80b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

adafruit_display_text/bitmap_label.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -300,13 +300,13 @@ def _text_bounding_box(
300300

301301
y_offset_tight = self._ascent // 2
302302

303-
newline = False
303+
newlines = 0
304304
line_spacing = self._line_spacing
305305

306306
for char in text:
307307

308308
if char == "\n": # newline
309-
newline = True
309+
newlines += 1
310310

311311
else:
312312

@@ -315,13 +315,13 @@ def _text_bounding_box(
315315
if my_glyph is None: # Error checking: no glyph found
316316
print("Glyph not found: {}".format(repr(char)))
317317
else:
318-
if newline:
319-
newline = False
318+
if newlines:
320319
xposition = x_start # reset to left column
321-
yposition = yposition + self._line_spacing_ypixels(
322-
font, line_spacing
323-
) # Add a newline
324-
lines += 1
320+
yposition += (
321+
self._line_spacing_ypixels(font, line_spacing) * newlines
322+
) # Add the newline(s)
323+
lines += newlines
324+
newlines = 0
325325
if xposition == x_start:
326326
if left is None:
327327
left = 0

0 commit comments

Comments
 (0)