@@ -221,6 +221,14 @@ def __init__(
221221 self .local_group = None
222222
223223 self ._text = text
224+ self ._baseline = - 1.0
225+
226+ self .base_alignment = base_alignment
227+
228+ if self .base_alignment :
229+ self ._y_offset = 0
230+ else :
231+ self ._y_offset = self ._get_ascent () // 2
224232
225233 def _get_ascent_descent (self ):
226234 """ Private function to calculate ascent and descent font values """
@@ -298,7 +306,10 @@ def anchor_point(self):
298306
299307 @anchor_point .setter
300308 def anchor_point (self , new_anchor_point ):
301- self ._anchor_point = new_anchor_point
309+ if new_anchor_point [1 ] == self ._baseline :
310+ self ._anchor_point = (new_anchor_point [0 ], - 1.0 )
311+ else :
312+ self ._anchor_point = new_anchor_point
302313 self .anchored_position = (
303314 self ._anchored_position
304315 ) # update the anchored_position using setter
@@ -319,11 +330,17 @@ def anchored_position(self, new_position):
319330 - (self ._bounding_box [0 ] * self .scale )
320331 - round (self ._anchor_point [0 ] * (self ._bounding_box [2 ] * self .scale ))
321332 )
322- self .y = int (
323- new_position [1 ]
324- - (self ._bounding_box [1 ] * self .scale )
325- - round (self ._anchor_point [1 ] * self ._bounding_box [3 ] * self .scale )
326- )
333+ if self ._anchor_point [1 ] == self ._baseline :
334+ self .y = int (
335+ new_position [1 ]
336+ - (self ._y_offset * self .scale )
337+ )
338+ else :
339+ self .y = int (
340+ new_position [1 ]
341+ - (self ._bounding_box [1 ] * self .scale )
342+ - round (self ._anchor_point [1 ] * self ._bounding_box [3 ] * self .scale )
343+ )
327344
328345 @property
329346 def scale (self ):
0 commit comments