note 100713 added to function.imagettftext
| From: | JohnConde at osu1 dot php dot net | Date: | Mon, 01 Nov 2010 18:17:09 +0000 |
| Subject: | note 100713 added to function.imagettftext | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-173676@lists.php.net to get a copy of this message | ||
If you want to create a paragraph you will need to break your text up into lines and then place each
line individually one below the next.
Here's a basic example of how to do that:
<?php
// Basic font settings
$font ='./times.ttf';
$font_size = 15;
$font_color = 0x000000
// Text to be placed as a paragraph
$text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer non nunc lectus.
Curabitur hendrerit bibendum enim dignissim tempus. Suspendisse non ipsum auctor metus consectetur
eleifend. Fusce cursus ullamcorper sem nec ultricies. Aliquam erat volutpat. Vivamus massa justo,
pharetra et sodales quis, rhoncus in ligula. Integer dolor velit, ultrices in iaculis nec, viverra
ut nunc.';
// Break it up into pieces 125 characters long
$lines = explode('|', wordwrap($text, 115, '|'));
// Starting Y position
$y = 513;
// Loop through the lines and place them on the image
foreach ($lines as $line)
{
imagettftext($image, $font_size, 0, 50, $y, $font_color, $font, $line);
// Increment Y so the next line is below the previous line
$y += 23;
}
?>
----
Server IP: 192.41.42.26
Probable Submitter: 173.54.50.19
----
Manual Page -- http://www.php.net/manual/en/function.imagettftext.php
Edit -- https://master.php.net/note/edit/100713
Del: integrated -- https://master.php.net/note/delete/100713/integrated
Del: useless -- https://master.php.net/note/delete/100713/useless
Del: bad code -- https://master.php.net/note/delete/100713/bad+code
Del: spam -- https://master.php.net/note/delete/100713/spam
Del: non-english -- https://master.php.net/note/delete/100713/non-english
Del: in docs -- https://master.php.net/note/delete/100713/in+docs
Del: other reasons-- https://master.php.net/note/delete/100713
Reject -- https://master.php.net/note/reject/100713
Search -- https://master.php.net/manage/user-notes.php