Skip to content

Commit 45687ee

Browse files
committed
PyBadger handles External fonts and multi-line much better
1 parent 1fd9824 commit 45687ee

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

adafruit_pybadger.py

100644100755
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def show_badge(self, *, background_color=0xFF0000, foreground_color=0xFFFFFF,
334334
hello_label = Label(font=hello_font, text=hello_string)
335335
(_, _, width, height) = hello_label.bounding_box
336336
hello_label.x = ((self.display.width // (2 * hello_scale)) - width // 2)
337-
hello_label.y = int(height // (1.2 * hello_scale))
337+
hello_label.y = int(self.display.height * (0.117 / hello_scale))
338338
hello_label.color = background_text_color
339339
hello_group.append(hello_label)
340340

@@ -343,16 +343,16 @@ def show_badge(self, *, background_color=0xFF0000, foreground_color=0xFFFFFF,
343343
my_name_is_label = Label(font=my_name_is_font, text=my_name_is_string)
344344
(_, _, width, height) = my_name_is_label.bounding_box
345345
my_name_is_label.x = ((self.display.width // (2 * my_name_is_scale)) - width // 2)
346-
my_name_is_label.y = int(height // (0.42 * my_name_is_scale))
346+
my_name_is_label.y = int(self.display.height * (0.28 / my_name_is_scale))
347347
my_name_is_label.color = background_text_color
348348
my_name_is_group.append(my_name_is_label)
349349

350350
name_scale = name_scale
351351
name_group = displayio.Group(scale=name_scale)
352-
name_label = Label(font=name_font, text=name_string)
352+
name_label = Label(font=name_font, text=name_string, line_spacing=0.75)
353353
(_, _, width, height) = name_label.bounding_box
354354
name_label.x = ((self.display.width // (2 * name_scale)) - width // 2)
355-
name_label.y = int(height // (0.17 * name_scale))
355+
name_label.y = int(self.display.height * (0.65 / name_scale))
356356
name_label.color = foreground_text_color
357357
name_group.append(name_label)
358358

0 commit comments

Comments
 (0)