I'm loading text on to a png file of width xWidth and height xHeight.
Can anyone think of a way to work out the x/y position so that the text is aligned?
Printable View
I'm loading text on to a png file of width xWidth and height xHeight.
Can anyone think of a way to work out the x/y position so that the text is aligned?
SOlution...
PHP Code:$bbox = imagettfbbox (10, 0, $font, $text);
$textLength = $bbox[2] - $bbox[0];
$centreDocument = $imgWidth / 2;
$x = $centreDocument - ($textLength / 2);
imagettftext($im, 10, 0, $x, 20, $black, $font, $text);