note 86854 added to function.imagettfbbox
| From: | Anonymous at osu1 dot php dot net | Date: | Thu, 06 Nov 2008 19:18:32 +0000 |
| Subject: | note 86854 added to function.imagettfbbox | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-146246@lists.php.net to get a copy of this message | ||
SIMPLE OVERLOADED FUNCTION: Adds TTF Center and Right Alignment to co ordintate points.
Correctly demonstrates the use of the bouning box TTF function and the array of coordinates that it
returns.
After obtaining values and adjusting based on a set of values [L, C, R], it uses simple math based
of the length of the text to move it from the origin (x = 0 )
function imagettftextalign($image, $size, $angle, $x, $y, $color, $font, $text,
$alignment='L')
{
//check width of the text
$bbox = imagettfbbox ($size, $angle, $font, $text);
$textWidth = $bbox[2] - $bbox[0];
switch ($alignment) {
case "R":
$x -= $textWidth;
break;
case "C":
$x -= $textWidth / 2;
break;
}
//write text
imagettftext ($image, $size, $angle, $x, $y, $color, $font, $text);
}
----
Server IP: 209.41.74.194
Probable Submitter: 68.82.101.130
----
Manual Page -- http://www.php.net/manual/en/function.imagettfbbox.php
Edit -- https://master.php.net/note/edit/86854
Del: integrated -- https://master.php.net/note/delete/86854/integrated
Del: useless -- https://master.php.net/note/delete/86854/useless
Del: bad code -- https://master.php.net/note/delete/86854/bad+code
Del: spam -- https://master.php.net/note/delete/86854/spam
Del: non-english -- https://master.php.net/note/delete/86854/non-english
Del: in docs -- https://master.php.net/note/delete/86854/in+docs
Del: other reasons-- https://master.php.net/note/delete/86854
Reject -- https://master.php.net/note/reject/86854
Search -- https://master.php.net/manage/user-notes.php