Random Text Script

liunx

Guest
Hey gang,<br /><br />I am using a script to display random sigs at the bottom of my posts. The problem is that it only allows one line. Is there a change I can make to allow for word wrap so I can use a larger font or more text?<br /><br />Here is the script.<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><?php<br />$font_file = $_SERVER[DOCUMENT_ROOT]."/sigs/sigimage/Therfont.ttf";//The font I am using<br />$font_size = 8;// Font size<br />$y_start = 25;<br />$angle = 0;<br />$max_width = 450;// Maximum width for test<br /><br />$sigs_array = file("sigs.txt");// Where my sigs are comming from<br />srand((double) microtime() * 10000000);<br />$sigs = array_rand($sigs_array);<br /><br />$line_width = imagettfbbox($font_size, 0, $font_file, $sigs_array[$sigs]);<br /><br />header("Content-type: image/png");<br />$im = imagecreatefrompng("blank.png");//What the sigs are being displayed on<br />$red = imagecolorallocate($im, 0, 0, 0);<br /><br />imagettftext($im, $font_size, $angle, $x_start, $y_start, $red, $font_file, $sigs_array[$sigs]);<br /><br />imagepng($im);<br />imagedestroy($im);<br />?><!--c2--></div><!--ec2--><br /><br />I know that file( ) only pulls one line so is there something that allows me to put multiple lines or wrap the text?<!--content-->
Since you're turning the text into an image on the fly... I'm not so sure. <br /><br />But what <b>should</b> work is putting either a carriage return or <br> in the string where you want the line break.<!--content-->
So Jack,<br /><br />Is there an easier way of doing this?<!--content-->
I've seen lots of classes devoted to image manipulation and creation. Are you hard coding this script into the TCH forums? I'd imagine there'd be an add on for invision board.<br /><br />Sorry I can't be more help.<!--content-->
Yep, I am having it pull it as an image from my sig here.<!--content-->
Rob, file() reads the file you specify and returns an array from which each element corresponds to a line in the file, with the newline still attached.<!--content-->
I want it to take 2 lines and display it as 2 lines. What should I use to replace file()?<!--content-->
Oh! Sorry, I was very sleepy when I red this the first time and I didn't fully understand what you wanted to do.<br /><br />OK, in that case, you're probably interested in <a href="http://php.net/manual/en/function.fgets.php" target="_blank">fgets()</a>. It reads bytes from a file. It ends reading when the specified number of bytes as been read or when a newline is found.<br /><br />Just call it two times and you'll have two lines from your sigs.txt file <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /><br />(I'm in a bit of a hurry, now but I think you can manage with this. If you still need help let me know. I'll drop by again in a couple of hours.)<!--content-->
 
Back
Top