Ttf/gd/php

software development

#1

I am having problems with making dynamic text with the imagettftext() function in PHP. I have uploaded the script to other servers and it seems to work fine, and yes I made sure I uploaded a copy of the font. The image comes up fine, just no text :(. Here is the script

header(“Content-type: image/png”);
$string = $_GET[‘text’];
$font = “…/font/verdana.ttf”;
$im = imagecreatefrompng("…/images/lgbutton.png");
$gray = imagecolorallocate($im, 167, 167, 167);
$px = (imagesx($im) - 7.5 * strlen($string)) / 2;
imagettftext($im, 10, 0, $px, 23, $gray, $font, $string);
imagepng($im);
imagedestroy($im);

Any thought/feelings/ideas would be appreciated

Mike


#2

I don’t think using such commands for Verdana is necessary. 99% of PC’s have the font installed with the OS.


#3

It is required when the webserver is running linux or windows, otherwise PHP does not have a clue what font to render it to when rendering a TTF font to an image using PHP. I could substitute it with an obscure font and I will still not work. My own webservers will handle it and render it without issue (not hosted by dreamhost and built by me) but dreamhost’s php does not seem to be compiled preperly or something


#4

I remember posting about this problem in the past, so I did a search for “imagettftext” and came up with the following:

http://discussion.dreamhost.com/showflat.pl?Cat=&Board=forum_troubleshooting&Number=13390&page=&view=&sb=&o=&vc=1

My suspicion was that it’s a configuration problem. If that theory is correct, it would require an email to support suggesting that they recompile PHP with the correct option.


#5

I already tried the imagefttext() function and it is still broken :(, I will contact support. Thanks