From 7e79bf3307ebc152e4f5d7b85c3b38959856628c Mon Sep 17 00:00:00 2001 From: Neradoc Date: Fri, 10 Mar 2023 03:53:41 +0100 Subject: [PATCH] Fix multiple lines in bitmap label causing an error --- adafruit_display_text/bitmap_label.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/adafruit_display_text/bitmap_label.py b/adafruit_display_text/bitmap_label.py index d2a994a..bc91cc8 100755 --- a/adafruit_display_text/bitmap_label.py +++ b/adafruit_display_text/bitmap_label.py @@ -293,13 +293,13 @@ def _text_bounding_box( y_offset_tight = self._ascent // 2 - newline = False + newlines = 0 line_spacing = self._line_spacing for char in text: if char == "\n": # newline - newline = True + newlines += 1 else: @@ -308,13 +308,13 @@ def _text_bounding_box( if my_glyph is None: # Error checking: no glyph found print("Glyph not found: {}".format(repr(char))) else: - if newline: - newline = False + if newlines: xposition = x_start # reset to left column - yposition = yposition + self._line_spacing_ypixels( - font, line_spacing - ) # Add a newline - lines += 1 + yposition += ( + self._line_spacing_ypixels(font, line_spacing) * newlines + ) # Add the newline(s) + lines += newlines + newlines = 0 if xposition == x_start: if left is None: left = 0