note 26160 added to function.imagettftext
| From: | php dot net at hatterscheid dot info | Date: | Sun, 20 Oct 2002 17:13:08 +0000 |
| Subject: | note 26160 added to function.imagettftext | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-38328@lists.php.net to get a copy of this message | ||
If you want more space between the chars. You can use this example:
<?
header("Content-type: image/png");
$imagewidth = 250;
$imageheight = 50;
$fontsize = 36;
$space = 6;
$xpos = 20;
$ypos = 40;
$text = "Example";
$im = imagecreate ($imagewidth, $imageheight);
$bgcolor = ImageColorAllocate ($im, 202, 112, 112);
$font = ImageColorAllocate ($im, 255, 255, 255);
function make_text($char, $xpos, $fontsize, $space, $imagewidth, $imageheight) {
global $im, $ypos, $font;
$thetextbox = ImageTTFBBox ($fontsize, 0, "arial.ttf", $char);
ImageTTFText ($im, $fontsize, 0, $xpos, $ypos, $font, "arial.ttf", $char);
return $xpos+$thetextbox[4]+$space;
}
for($i=0;substr($text, $i,1);$i++) {
$xpos = make_text(substr($text, $i,1), $xpos, $fontsize, $space, $imagewidth, $imageheight);
}
Imagepng ($im);
ImageDestroy ($im);
?>
--
http://www.php.net/manual/en/function.imagettftext.php
http://master.php.net/manage/user-notes.php?action=edit+26160
http://master.php.net/manage/user-notes.php?action=delete+26160
http://master.php.net/manage/user-notes.php?action=reject+26160