Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions adafruit_display_text/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ def __init__(
super().__init__(max_size=1, x=x, y=y, scale=1, **kwargs)

self._font = font
self._ascent, self._descent = self._get_ascent_descent()
self.palette = Palette(2)
self._color = color
self._background_color = background_color
Expand Down
6 changes: 3 additions & 3 deletions adafruit_display_text/bitmap_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def _reset_text(
if self.base_alignment:
label_position_yoffset = 0
else:
label_position_yoffset = self._get_ascent() // 2
label_position_yoffset = self._ascent // 2

self.tilegrid = displayio.TileGrid(
self.bitmap,
Expand Down Expand Up @@ -325,7 +325,7 @@ def _line_spacing_ypixels(font, line_spacing: float) -> int:
def _text_bounding_box(
self, text: str, font, line_spacing: float
) -> Tuple[int, int, int, int, int, int]:
ascender_max, descender_max = self._get_ascent_descent()
ascender_max, descender_max = self._ascent, self._descent

lines = 1

Expand All @@ -337,7 +337,7 @@ def _text_bounding_box(
right = x_start
top = bottom = y_start

y_offset_tight = self._get_ascent() // 2
y_offset_tight = self._ascent // 2

newline = False

Expand Down
6 changes: 3 additions & 3 deletions adafruit_display_text/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def _create_background_box(self, lines: int, y_offset: int) -> None:
y_box_offset = self._bounding_box[1]

else: # draw a "loose" bounding box to include any ascenders/descenders.
ascent, descent = self._get_ascent_descent()
ascent, descent = self._ascent, self._descent

if (
self._label_direction == "UPR"
Expand Down Expand Up @@ -225,7 +225,7 @@ def _update_background_color(self, new_color: int) -> None:
self._background_color = new_color

lines = self._text.rstrip("\n").count("\n") + 1
y_offset = self._get_ascent() // 2
y_offset = self._ascent // 2

if not self._added_background_tilegrid: # no bitmap is in the self Group
# add bitmap if text is present and bitmap sizes > 0 pixels
Expand Down Expand Up @@ -279,7 +279,7 @@ def _update_text(
if self.base_alignment:
self._y_offset = 0
else:
self._y_offset = self._get_ascent() // 2
self._y_offset = self._ascent // 2

if self._label_direction == "RTL":
left = top = bottom = 0
Expand Down