Skip to content

Commit c87f120

Browse files
authored
Merge pull request #113 from FoamyGuy/text_outline
support for outlined text
2 parents 149d4f3 + ba25bfa commit c87f120

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

adafruit_portalbase/__init__.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from adafruit_bitmap_font import bitmap_font
2929
from adafruit_display_text import wrap_text_to_lines
3030
from adafruit_display_text.bitmap_label import Label
31+
from adafruit_display_text.outlined_label import OutlinedLabel
3132

3233
__version__ = "0.0.0+auto.0"
3334
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_PortalBase.git"
@@ -164,6 +165,8 @@ def add_text( # noqa: PLR0913 Too many arguments in function definition
164165
text_scale=1,
165166
line_spacing=1.25,
166167
text_anchor_point=(0, 0.5),
168+
outline_size=0,
169+
outline_color=0x000000,
167170
is_data=True,
168171
text=None,
169172
) -> int:
@@ -222,6 +225,8 @@ def add_text( # noqa: PLR0913 Too many arguments in function definition
222225
"line_spacing": line_spacing,
223226
"anchor_point": text_anchor_point,
224227
"is_data": bool(is_data),
228+
"outline_size": outline_size,
229+
"outline_color": outline_color,
225230
}
226231
self._text.append(text_field)
227232

@@ -279,11 +284,20 @@ def set_text(self, val, index=0): # noqa: PLR0912 Too many branches
279284
print("Creating text area with :", string)
280285
if len(string) > 0:
281286
if self._text[index]["label"] is None:
282-
self._text[index]["label"] = Label(
283-
self._fonts[self._text[index]["font"]],
284-
text=string,
285-
scale=self._text[index]["scale"],
286-
)
287+
if self._text[index]["outline_size"] == 0:
288+
self._text[index]["label"] = Label(
289+
self._fonts[self._text[index]["font"]],
290+
text=string,
291+
scale=self._text[index]["scale"],
292+
)
293+
else:
294+
self._text[index]["label"] = OutlinedLabel(
295+
self._fonts[self._text[index]["font"]],
296+
text=string,
297+
scale=self._text[index]["scale"],
298+
outline_size=self._text[index]["outline_size"],
299+
outline_color=self._text[index]["outline_color"],
300+
)
287301
if index_in_root_group is not None:
288302
self.root_group[index_in_root_group] = self._text[index]["label"]
289303
else:

0 commit comments

Comments
 (0)