function imagettftextSp($image, $size, $angle, $x, $y, $color, $font, $text, $spacing = 0)
{
if ($spacing == 0)
{
imagettftext($image, $size, $angle, $x, $y, $color, $font, $text);
}
else
{
$temp_x = $x;
for ($i = 0; $i < strlen($text); $i++)
{
$bbox = imagettftext($image, $size, $angle, $temp_x, $y, $color, $font, $text[$i]);
$temp_x += $spacing + ($bbox[2] - $bbox[0]);
}
}
}
和电话:
imagettftextSp($image, 30, 0, 30, 30, $black, 'arial.ttf', $text, 23);
函数参数顺序符合标准的imagettftext参数顺序,最后一个参数是可选的$spacing参数.如果未设置或传递的值为0,则不设置字距调整/字母间距.