Skip to content

Commit 759d9fc

Browse files
authored
Merge pull request #163 from cobacdavid/main
fix text bbox height
2 parents c727733 + 5f8931f commit 759d9fc

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

library/lcd/lcd_comm.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,11 @@ def DisplayText(
208208
# Draw text with specified color & font
209209
font = ImageFont.truetype("./res/fonts/" + font, font_size)
210210
d = ImageDraw.Draw(text_image)
211-
d.text((x, y), text, font=font, fill=font_color)
212211

213212
# Crop text bitmap to keep only the text (also crop if text overflows display)
214213
left, top, text_width, text_height = d.textbbox((0, 0), text, font=font)
214+
d.text((x-left, y-top), text, font=font, fill=font_color)
215+
215216
text_image = text_image.crop(box=(
216217
x, y,
217218
min(x + text_width, self.get_width()),

0 commit comments

Comments
 (0)