Skip to content

PyBadger handles External fonts and multi-line much better #12

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 3 commits into from
Dec 13, 2019
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
29 changes: 13 additions & 16 deletions adafruit_pybadger.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -260,29 +260,29 @@ def show_business_card(self, *, image_name=None, name_string=None, name_scale=1,
if name_string:
name_group = displayio.Group(scale=name_scale)
name_label = Label(name_font, text=name_string)
(_, _, width, height) = name_label.bounding_box
(_, _, width, _) = name_label.bounding_box
name_label.x = ((self.display.width // (2 * name_scale)) - width // 2)
name_label.y = int(height // (0.15 * name_scale))
name_label.y = int(self.display.height * (0.73 / name_scale))
name_label.color = 0xFFFFFF
name_group.append(name_label)
business_card_splash.append(name_group)
if email_string_one:
email_group_one = displayio.Group(scale=email_scale_one)
email_label_one = Label(email_font_one, text=email_string_one)
(_, _, width, height) = email_label_one.bounding_box
(_, _, width, _) = email_label_one.bounding_box
email_label_one.width = self.display.width
email_label_one.x = ((self.display.width // (2 * email_scale_one)) - width // 2)
email_label_one.y = int(height // (0.13 * email_scale_one))
email_label_one.y = int(self.display.height * (0.84 / email_scale_one))
email_label_one.color = 0xFFFFFF
email_group_one.append(email_label_one)
business_card_splash.append(email_group_one)
if email_string_two:
email_group_two = displayio.Group(scale=email_scale_two)
email_label_two = Label(email_font_two, text=email_string_two)
(_, _, width, height) = email_label_two.bounding_box
(_, _, width, _) = email_label_two.bounding_box
email_label_two.width = self.display.width
email_label_two.x = ((self.display.width // (2 * email_scale_two)) - width // 2)
email_label_two.y = int(height // (0.12 * email_scale_two))
email_label_two.y = int(self.display.height * (0.91 / email_scale_two))
email_label_two.color = 0xFFFFFF
email_group_two.append(email_label_two)
business_card_splash.append(email_group_two)
Expand Down Expand Up @@ -329,30 +329,27 @@ def show_badge(self, *, background_color=0xFF0000, foreground_color=0xFFFFFF,
(int(self.display.height * 0.5)), fill=foreground_color)
splash.append(rect)

hello_scale = hello_scale
hello_group = displayio.Group(scale=hello_scale)
hello_label = Label(font=hello_font, text=hello_string)
(_, _, width, height) = hello_label.bounding_box
(_, _, width, _) = hello_label.bounding_box
hello_label.x = ((self.display.width // (2 * hello_scale)) - width // 2)
hello_label.y = int(height // (1.2 * hello_scale))
hello_label.y = int(self.display.height * (0.117 / hello_scale))
hello_label.color = background_text_color
hello_group.append(hello_label)

my_name_is_scale = my_name_is_scale
my_name_is_group = displayio.Group(scale=my_name_is_scale)
my_name_is_label = Label(font=my_name_is_font, text=my_name_is_string)
(_, _, width, height) = my_name_is_label.bounding_box
(_, _, width, _) = my_name_is_label.bounding_box
my_name_is_label.x = ((self.display.width // (2 * my_name_is_scale)) - width // 2)
my_name_is_label.y = int(height // (0.42 * my_name_is_scale))
my_name_is_label.y = int(self.display.height * (0.28 / my_name_is_scale))
my_name_is_label.color = background_text_color
my_name_is_group.append(my_name_is_label)

name_scale = name_scale
name_group = displayio.Group(scale=name_scale)
name_label = Label(font=name_font, text=name_string)
(_, _, width, height) = name_label.bounding_box
name_label = Label(font=name_font, text=name_string, line_spacing=0.75)
(_, _, width, _) = name_label.bounding_box
name_label.x = ((self.display.width // (2 * name_scale)) - width // 2)
name_label.y = int(height // (0.17 * name_scale))
name_label.y = int(self.display.height * (0.65 / name_scale))
name_label.color = foreground_text_color
name_group.append(name_label)

Expand Down