Using TTF within an image
| From: | CDitty | Date: | Fri, 04 Jul 2003 06:35:29 +0000 |
| Subject: | Using TTF within an image | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-153957@lists.php.net to get a copy of this message | ||
Can someone please show me how to change the display font to a TTF in this code? I looked at the online manual under imageloadfont(), but I did not understand it enough. I have the MS TTFs installed on my server and they are working correctly.
Thanks
Chris
<?php
header ("Content-type: image/png");
$string = "Text message goes here";
$font = "2";
$width = ImageFontWidth($font) * strlen($string);
$height = ImageFontHeight($font);
$im = @imagecreate ($width,$height);
$background_color = imagecolorallocate ($im, 255, 255, 255); //white background
$text_color = imagecolorallocate ($im, 0, 0,0);//black text
imagestring ($im, $font, 0, 0, $string, $text_color);
imagepng ($im);
?>