tw, th = draw.textsize(text)

修改为

left, top, right, bottom = draw.textbbox((0, 0), text)
tw, th = right - left, bottom - top