@MauriceMeilleur
not sure I understand your question correctly.
my assumption is you want to specify a position for the first baseline and have the textbox draw the text so the first line is at that given position no matter the lineheight or font size?
the following script should do that. I tested a few fonts, fontSizes and lineHeights.
# -----------------------------------
# S E T T I N G S
fnt = 'Helvetica'
fnt_s = 16 # the fontsize
lh = fnt_s * 1.6 # the lineheight
txt = 'Testing the position of the baseline and the setting of the line height in drawBot. '*30
tbx_x = 100 # x position of the textbox
frst_bl_y = 657 # the exact position of the first baseline within the textbox
tbx_w = 350 # textbox width
tbx_h = 400 # textbox heigth
# --------------
# F U N C T I O N S
def calc_baseline_offset(fnt, fnt_s, lh):
'''calculates the position of the first baseline of a placeholder textbox and returns the distance from the top edge of the textbox'''
fstr = FormattedString('Hm', font = fnt, fontSize = fnt_s, lineHeight = lh)
temp_first_baseline = textBoxBaselines(fstr, (0, 0, fnt_s * 3, fnt_s * lh))[0][1]
return temp_first_baseline - (fnt_s * lh)
# -----------------------------------
# D R A W I N G S
newPage('A4')
fstr = FormattedString(txt, font = fnt, fontSize = fnt_s, lineHeight = lh)
rect(tbx_x - 20, frst_bl_y, tbx_w + 40, -1) # drawing the first baseline
y_shift = calc_baseline_offset(fnt, fnt_s, lh)
tbx_y = frst_bl_y - tbx_h - y_shift # the y position for the textbox so that the first baseline stays at the given value
fill(1, 0, 0, .1)
rect(tbx_x, tbx_y, tbx_w, tbx_h)
textBox(fstr, (tbx_x, tbx_y, tbx_w, tbx_h))
# drawing all the baselines
for x, y in textBoxBaselines(fstr, (tbx_x, tbx_y, tbx_w, tbx_h)):
rect(tbx_x, y, tbx_w, -1)