@@ -115,22 +115,24 @@ def __init__(
115115 )
116116 ) # initialize with a blank tilegrid placeholder for background
117117
118- self ._padding_top = padding_top
119- self ._padding_bottom = padding_bottom
120- self ._padding_left = padding_left
121- self ._padding_right = padding_right
118+ self ._padding = (padding_left , padding_top , padding_right , padding_bottom )
119+ # self._padding_top = padding_top
120+ # self._padding_bottom = padding_bottom
121+ # self._padding_left = padding_left
122+ # self._padding_right = padding_right
122123
123124 if text is not None :
124125 self ._update_text (str (text ))
125126
126127 def _create_background_box (self , lines , y_offset ):
127128
129+ left = self ._boundingbox [0 ]
130+
128131 if self ._background_tight : # draw a tight bounding box
129132 box_width = self ._boundingbox [2 ]
130133 box_height = self ._boundingbox [3 ]
131134 x_box_offset = 0
132- y_box_offset = self ._bounding_box [1 ]
133- left = self ._bounding_box [0 ]
135+ y_box_offset = self ._boundingbox [1 ]
134136
135137 else : # draw a "loose" bounding box to include any ascenders/descenders.
136138
@@ -145,15 +147,17 @@ def _create_background_box(self, lines, y_offset):
145147 ascender_max = max (ascender_max , this_glyph .height + this_glyph .dy )
146148 descender_max = max (descender_max , - this_glyph .dy )
147149
148- box_width = self ._boundingbox [2 ] + self ._padding_left + self ._padding_right
149- x_box_offset = - self ._padding_left
150+ box_width = (
151+ self ._boundingbox [2 ] + self ._padding [0 ] + self ._padding [3 ]
152+ ) # left + right padding
153+ x_box_offset = - self ._padding [0 ] # left padding
150154 box_height = (
151155 (ascender_max + descender_max )
152156 + int ((lines - 1 ) * self .height * self ._line_spacing )
153- + self ._padding_top
154- + self ._padding_bottom
157+ + self ._padding [ 1 ] # top padding
158+ + self ._padding [ 2 ] # bottom padding
155159 )
156- y_box_offset = - ascender_max + y_offset - self ._padding_top
160+ y_box_offset = - ascender_max + y_offset - self ._padding [ 1 ] # top padding
157161
158162 self ._update_background_color (self ._background_color )
159163 box_width = max (0 , box_width ) # remove any negative values
0 commit comments