Skip to content

Commit 7e79bf3

Browse files
committed
Fix multiple lines in bitmap label causing an error
1 parent 9112015 commit 7e79bf3

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
@@ -293,13 +293,13 @@ def _text_bounding_box(
293293

294294
y_offset_tight = self._ascent // 2
295295

296-
newline = False
296+
newlines = 0
297297
line_spacing = self._line_spacing
298298

299299
for char in text:
300300

301301
if char == "\n": # newline
302-
newline = True
302+
newlines += 1
303303

304304
else:
305305

@@ -308,13 +308,13 @@ def _text_bounding_box(
308308
if my_glyph is None: # Error checking: no glyph found
309309
print("Glyph not found: {}".format(repr(char)))
310310
else:
311-
if newline:
312-
newline = False
311+
if newlines:
313312
xposition = x_start # reset to left column
314-
yposition = yposition + self._line_spacing_ypixels(
315-
font, line_spacing
316-
) # Add a newline
317-
lines += 1
313+
yposition += (
314+
self._line_spacing_ypixels(font, line_spacing) * newlines
315+
) # Add the newline(s)
316+
lines += newlines
317+
newlines = 0
318318
if xposition == x_start:
319319
if left is None:
320320
left = 0

0 commit comments

Comments
 (0)