Center variable text length on an image
Posted: Thu Apr 03, 2008 9:34 pm
I am completely new to GD and having a minor problem. I have been able to get text on an image and it looks great - problem is that the text will always be a different length and as such the text will not be centered everytime.
How do I set it up so the starting pixel is variable depending on the length of the string. The image is always going to be 800x600.
This is what I am using, but obviously this is not variable.
imagettftext($TheImage, 30, 0, 400, 260, $ColorText, "Arial.ttf", $name);
Also, as a side note. I have an arial.ttf file in the same folder as the script, but it doesn't seem to see it, is there a type of font specific to GD that needs to be used or can it be any font file.
Thanks
How do I set it up so the starting pixel is variable depending on the length of the string. The image is always going to be 800x600.
This is what I am using, but obviously this is not variable.
imagettftext($TheImage, 30, 0, 400, 260, $ColorText, "Arial.ttf", $name);
Also, as a side note. I have an arial.ttf file in the same folder as the script, but it doesn't seem to see it, is there a type of font specific to GD that needs to be used or can it be any font file.
Thanks