Forum Moderators: coopster
[edited by: dreamcatcher at 6:12 am (utc) on Sep. 1, 2007]
[edit reason] Tidied up url. [/edit]
There is something in one of the user contributions on the PHP site which will allow me to justify text left, right and center, but nothing to allow me to create a block which lines up to the left and right egde in a block.
It may be a case of splitting each word into individual text boxes and working out how many can fit on a line, then adjusting the spacing between them accordingly... Fun! :o\
function textleftpos($fontsize, $text_to_display) {
$imagewidth = 60;
$text_left_position = ($imagewidth - (intval(((strlen($text_to_display) * imagefontwidth($fontsize)) / 2))));
return $text_left_position;
}
$imagename = "image_name.png";
$image1 = @imagecreatefrompng($imagename);
$text_top_pos = "150";
$maroon_text_color = imagecolorallocate($image1, 146, 2, 2);
imagestring($image1, 5, textleftpos(5, "Text to Display"), $text_top_pos, "Text to Display", $maroon_text_color);
header("Content-type: image/png");
imagepng($image1);
imagedestroy($image1);
Basically, the road I'm going down with this is as follows:
Once I've got it sorted I'll try and post some tidied-up code here for others.