Skip to content

Fix multiple lines in bitmap label causing an error #184

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
Mar 13, 2023
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
16 changes: 8 additions & 8 deletions adafruit_display_text/bitmap_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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
Expand Down