note 60547 added to function.imagettftext
| From: | Mer`Zikain at osu1 dot php dot net | Date: | Tue, 10 Jan 2006 20:41:23 +0000 |
| Subject: | note 60547 added to function.imagettftext | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-101519@lists.php.net to get a copy of this message | ||
I was looking for a way to add kerning to my text and finally just made this function to do it. Of
course, if you're generating the size of the image based on the text you're putting in it,
you'll have to figure out the new size to fit the new text width but I'm sure you can
figure that out.
for($i=0;$i<strlen($text);$i++){
// Get single character
$value=substr($text,$i,1);
if($pval){ // check for existing previous character
list($lx,$ly,$rx,$ry) = imagettfbbox($fontsize,0,$font,$pval);
$nxpos+=$rx+3;
}else{
$nxpos=0;
}
// Add the letter to the image
imagettftext($im, $fontsize, 0, $nxpos, $ypos, $fontcolor, $font, $value);
$pval=$value; // save current character for next loop
}
----
Manual Page -- http://www.php.net/manual/en/function.imagettftext.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+60547
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60547&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60547&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60547&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60547&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60547&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60547&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60547&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+60547&report=yes
Search -- http://master.php.net/manage/user-notes.php