note 75718 added to function.imagettftext
| From: | Lassialatthegooglemaildotcom at osu1 dot php dot net | Date: | Wed, 13 Jun 2007 07:42:20 +0000 |
| Subject: | note 75718 added to function.imagettftext | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-127439@lists.php.net to get a copy of this message | ||
Creating multiline text with GD is bit complicated, one of the issues I've ran to is how to set
line spacing, a normal feature in all type setting (even type writers). By default, line spacing
with imagettftext seems to be 150 % or more, too much for me anyhow. Thus I've used the
function below to get the lines closer to each other. By default, it appears to create 100 %
linespacing, but it has not been tested thoroughly.
null imagettfmultilinetext
(resource $image, float $size, float $angle, int $x, int $y, int $color, string $fontfile, string
$text , $spacing)
spacing is a coefficient, comparable to Line spacing in a word processors or graphics software,
causing a shift relative to font size in the line spacing
<?php
function imagettfmultilinetext($image, $size, $angle, $x, $y, $color, $fontfile, $text, $spacing=1)
{
$lines=explode("\n",$text);
for($i=0; $i< count($lines); $i++)
{
$newY=$y+($i * $size * $spacing);
imagettftext($image, $size, $angle, $x, $newY, $color, $fontfile, $lines[$i], $spacing);
}
return null;
}
?>
----
Server IP: 62.237.7.3
Probable Submitter: 128.214.215.13
----
Manual Page -- http://www.php.net/manual/en/function.imagettftext.php
Edit -- https://master.php.net/note/edit/75718
Del: integrated -- https://master.php.net/note/delete/75718/integrated
Del: useless -- https://master.php.net/note/delete/75718/useless
Del: bad code -- https://master.php.net/note/delete/75718/bad+code
Del: spam -- https://master.php.net/note/delete/75718/spam
Del: non-english -- https://master.php.net/note/delete/75718/non-english
Del: in docs -- https://master.php.net/note/delete/75718/in+docs
Del: other reasons-- https://master.php.net/note/delete/75718
Reject -- https://master.php.net/note/reject/75718
Search -- https://master.php.net/manage/user-notes.php