Skip to content

support for outlined text #113

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
Aug 6, 2025
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
24 changes: 19 additions & 5 deletions adafruit_portalbase/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from adafruit_bitmap_font import bitmap_font
from adafruit_display_text import wrap_text_to_lines
from adafruit_display_text.bitmap_label import Label
from adafruit_display_text.outlined_label import OutlinedLabel

__version__ = "0.0.0+auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_PortalBase.git"
Expand Down Expand Up @@ -164,6 +165,8 @@ def add_text( # noqa: PLR0913 Too many arguments in function definition
text_scale=1,
line_spacing=1.25,
text_anchor_point=(0, 0.5),
outline_size=0,
outline_color=0x000000,
is_data=True,
text=None,
) -> int:
Expand Down Expand Up @@ -222,6 +225,8 @@ def add_text( # noqa: PLR0913 Too many arguments in function definition
"line_spacing": line_spacing,
"anchor_point": text_anchor_point,
"is_data": bool(is_data),
"outline_size": outline_size,
"outline_color": outline_color,
}
self._text.append(text_field)

Expand Down Expand Up @@ -279,11 +284,20 @@ def set_text(self, val, index=0): # noqa: PLR0912 Too many branches
print("Creating text area with :", string)
if len(string) > 0:
if self._text[index]["label"] is None:
self._text[index]["label"] = Label(
self._fonts[self._text[index]["font"]],
text=string,
scale=self._text[index]["scale"],
)
if self._text[index]["outline_size"] == 0:
self._text[index]["label"] = Label(
self._fonts[self._text[index]["font"]],
text=string,
scale=self._text[index]["scale"],
)
else:
self._text[index]["label"] = OutlinedLabel(
self._fonts[self._text[index]["font"]],
text=string,
scale=self._text[index]["scale"],
outline_size=self._text[index]["outline_size"],
outline_color=self._text[index]["outline_color"],
)
if index_in_root_group is not None:
self.root_group[index_in_root_group] = self._text[index]["label"]
else:
Expand Down