http://www.ffwbmarion.com/imagergd/t...it%20is%20test
How can I get this to wrap to a new line?
I cant figure out the imagettfbox
Printable View
http://www.ffwbmarion.com/imagergd/t...it%20is%20test
How can I get this to wrap to a new line?
I cant figure out the imagettfbox
Is this for H-R by any chance? :P
Yes it is ;)
Yay more good features
EDIT: Use wordwrap() ?
Gifts too :)
If only I could figure this out
Would this help
http://www.php.net/wordwrap
No but thanks tho. I already tried that.
Its something to do with imagettfbox
You mean imagettfbbox?
yea that :P
This was on php.net, helpful?
PHP Code:<?php
function imageWordWrapBBox ( $Text, $Width = 650, $FontSize = 10, $Font = './fonts/arial.ttf' )
{
$Words = split ( ' ', $Text );
$Lines = array ( );
$Line = '';
foreach ( $Words as $Word )
{
$Box = imagettfbbox ( $FontSize, 0, $Font, $Line . $Word );
$Size = $Box[4] - $Box[0];
if ( $Size > $Width )
{
$Lines[] = trim ( $Line );
$Line = '';
}
$Line .= $Word . ' ';
}
$Lines[] = trim ( $Line );
$Dimensions = imagettfbbox ( $FontSize, 0, $Font, 'AJLMYabdfghjklpqry019`@$^&*(,' );
$lineHeight = $Dimensions[1] - $Dimensions[5];
return array ( $lineHeight, $Lines, $lineHeight * count ( $Lines ) );
}
function imageWordWrap ( $Text, $Width, $Color, $X = 0, $Y = 0, $FontSize = 10, $Font = './fonts/arial.ttf' )
{
$Data = $this->imageWordWrapBBox ( $Text, $Width, $FontSize, $Font );
foreach ( $Data[1] as $Key => $Line )
{
$locX = $X;
$locY = $Y + ( $Key * $Data[0] );
imagettftext ( $this->Image, $FontSize, 0, $locX, $locY, $Color, $Font, $Line );
}
return $Data;
}
?>
Grr I need to start looking into GD again.
I stopped using it when I just couldnt find out aligning of the text pmsl.
Probs something which is REALLY easy aswell -.-
Aligns text all the way rightPHP Code:$arr = imagettfbbox(6.4, 0, $font, $text2);
$width = $arr[2] - $arr[0];
$x = imagesx($crop) - $width - $diff-21;
imagettftext($crop, 6.4, 0, $x, 70, $black, $font, stripslashes($text2));
like the name in this:
http://www.ffwbmarion.com/imagergd/t...s%20are%20here!
Oo. Thanks ALOT Kevin (:
*hugglez*
Try to find me word wrap PLZZZ
Yah, Hokay.
PHP Code:<?php
function imageWordWrapBBox ( $text, $Width, $FontSize, $Font)
{
$Words = split ( ' ', $Text );
$Lines = array ( );
$Line = '';
foreach ( $Words as $Word )
{
$Box = imagettfbbox ( $FontSize, 0, $Font, $Line . $Word );
$Size = $Box[4] - $Box[0];
if ( $Size > $Width )
{
$Lines[] = trim ( $Line );
$Line = '';
}
$Line .= $Word . ' ';
}
$Lines[] = trim ( $Line );
$Dimensions = imagettfbbox ( $FontSize, 0, $Font, 'AJLMYabdfghjklpqry019`@$^&*(,' );
$lineHeight = $Dimensions[1] - $Dimensions[5];
return array ( $lineHeight, $Lines, $lineHeight * count ( $Lines ) );
}
function imageWordWrap ( $Text, $Width, $Color, $X, $Y, $FontSize, $Font)
{
$Data = $this->imageWordWrapBBox ( $text, $Width, $FontSize, $Font );
foreach ( $Data[1] as $Key => $Line )
{
$locX = $X;
$locY = $Y + ( $Key * $Data[0] );
imagettftext ( $this->Image, $FontSize, 0, $locX, $locY, $Color, $Font, $Line );
}
return $Data;
}
$text = "hey";
$font = "Bold.ttf";
$url2 = "troph.gif";
$crop = imagecreatefromgif($url2);
$black = imagecolorallocate($crop, 127, 85, 43);
echo imageWordWrap($text, 650, $black, 0, 0, 6.4, $font);
?>
Fatal error: Call to a member function on a non-object in /home/ffwb/public_html/imagergd/test33.php on line 29
I get this
Kevin could you help me
At: http://mini-i.fm/imager/pedestal_new...on&badge=staff
I would like it to not go off the screen but automatically move the text to the left or whatever like in your version of the script.
Would you be able to help me on how to do this?
Edit: Don't actually think it would help && ignore my above post, I coded it wrong. It now works