@@ -81,7 +81,7 @@ class Label(LabelBase):
8181 :param str label_direction: string defining the label text orientation. There are 5
8282 configurations possibles ``LTR``-Left-To-Right ``RTL``-Right-To-Left
8383 ``UPD``-Upside Down ``UPR``-Upwards ``DWR``-Downwards. It defaults to ``LTR``
84- :param bool verbose: print debugging information in some internal functions. Default to False
84+ :param bool verbose: print debugging information in some internal functions. Default to False
8585
8686 """
8787
@@ -185,6 +185,7 @@ def _reset_text(
185185 y_offset = loose_y_offset
186186
187187 # Calculate the background size including padding
188+ tight_box_x = box_x
188189 box_x = box_x + self ._padding_left + self ._padding_right
189190 box_y = box_y + self ._padding_top + self ._padding_bottom
190191
@@ -245,17 +246,23 @@ def _reset_text(
245246 # Update bounding_box values. Note: To be consistent with label.py,
246247 # this is the bounding box for the text only, not including the background.
247248 if self ._label_direction in ("UPR" , "DWR" ):
249+ if self ._label_direction == "UPR" :
250+ top = self ._padding_right
251+ left = self ._padding_top
252+ if self ._label_direction == "DWR" :
253+ top = self ._padding_left
254+ left = self ._padding_bottom
248255 self ._bounding_box = (
249- self ._tilegrid .x ,
250- self ._tilegrid .y ,
256+ self ._tilegrid .x + left ,
257+ self ._tilegrid .y + top ,
251258 tight_box_y ,
252- box_x ,
259+ tight_box_x ,
253260 )
254261 else :
255262 self ._bounding_box = (
256- self ._tilegrid .x ,
257- self ._tilegrid .y ,
258- box_x ,
263+ self ._tilegrid .x + self . _padding_left ,
264+ self ._tilegrid .y + self . _padding_top ,
265+ tight_box_x ,
259266 tight_box_y ,
260267 )
261268
0 commit comments