更新时间:2023-12-04 10:00:58
您要为此使用imagettfbbox()来计算水平偏移量:
You want to use imagettfbbox() for this to calculate the horizontal offset:
$bbox = imagettfbbox(13, 0, $font_path, $text_line_1);
$xOffset = ($bbox[2] - $bbox[0]) / 2;
现在只需从所需位置减去偏移量即可.
Now just subtract the offset from your desired position and you are good to go.