Skip to content

Commit

Permalink
Merge pull request #186 from Neradoc/fix-bitmap-label-anchored-position
Browse files Browse the repository at this point in the history
Fix the position of bitmap_label with padding and anchored_position
  • Loading branch information
jposada202020 authored Mar 11, 2023
2 parents 9112015 + 14b1e72 commit 966c3ad
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions adafruit_display_text/bitmap_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class Label(LabelBase):
:param str label_direction: string defining the label text orientation. There are 5
configurations possibles ``LTR``-Left-To-Right ``RTL``-Right-To-Left
``UPD``-Upside Down ``UPR``-Upwards ``DWR``-Downwards. It defaults to ``LTR``
:param bool verbose: print debugging information in some internal functions. Default to False
:param bool verbose: print debugging information in some internal functions. Default to False
"""

Expand Down Expand Up @@ -185,6 +185,7 @@ def _reset_text(
y_offset = loose_y_offset

# Calculate the background size including padding
tight_box_x = box_x
box_x = box_x + self._padding_left + self._padding_right
box_y = box_y + self._padding_top + self._padding_bottom

Expand Down Expand Up @@ -245,17 +246,23 @@ def _reset_text(
# Update bounding_box values. Note: To be consistent with label.py,
# this is the bounding box for the text only, not including the background.
if self._label_direction in ("UPR", "DWR"):
if self._label_direction == "UPR":
top = self._padding_right
left = self._padding_top
if self._label_direction == "DWR":
top = self._padding_left
left = self._padding_bottom
self._bounding_box = (
self._tilegrid.x,
self._tilegrid.y,
self._tilegrid.x + left,
self._tilegrid.y + top,
tight_box_y,
box_x,
tight_box_x,
)
else:
self._bounding_box = (
self._tilegrid.x,
self._tilegrid.y,
box_x,
self._tilegrid.x + self._padding_left,
self._tilegrid.y + self._padding_top,
tight_box_x,
tight_box_y,
)

Expand Down

0 comments on commit 966c3ad

Please sign in to comment.