TCH-Rob Posted December 15, 2003 Posted December 15, 2003 Hey gang, 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? Here is the script. ><?php $font_file = $_SERVER[DOCUMENT_ROOT]."/sigs/sigimage/Therfont.ttf";//The font I am using $font_size = 8;// Font size $y_start = 25; $angle = 0; $max_width = 450;// Maximum width for test $sigs_array = file("sigs.txt");// Where my sigs are comming from srand((double) microtime() * 10000000); $sigs = array_rand($sigs_array); $line_width = imagettfbbox($font_size, 0, $font_file, $sigs_array[$sigs]); header("Content-type: image/png"); $im = imagecreatefrompng("blank.png");//What the sigs are being displayed on $red = imagecolorallocate($im, 0, 0, 0); imagettftext($im, $font_size, $angle, $x_start, $y_start, $red, $font_file, $sigs_array[$sigs]); imagepng($im); imagedestroy($im); ?> I know that file( ) only pulls one line so is there something that allows me to put multiple lines or wrap the text? Quote
surefire Posted December 15, 2003 Posted December 15, 2003 Since you're turning the text into an image on the fly... I'm not so sure. But what should work is putting either a carriage return or <br> in the string where you want the line break. Quote
TCH-Rob Posted December 15, 2003 Author Posted December 15, 2003 So Jack, Is there an easier way of doing this? Quote
surefire Posted December 15, 2003 Posted December 15, 2003 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. Sorry I can't be more help. Quote
TCH-Rob Posted December 15, 2003 Author Posted December 15, 2003 Yep, I am having it pull it as an image from my sig here. Quote
borfast Posted December 16, 2003 Posted December 16, 2003 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. Quote
TCH-Rob Posted December 16, 2003 Author Posted December 16, 2003 I want it to take 2 lines and display it as 2 lines. What should I use to replace file()? Quote
borfast Posted December 16, 2003 Posted December 16, 2003 (edited) Oh! Sorry, I was very sleepy when I red this the first time and I didn't fully understand what you wanted to do. OK, in that case, you're probably interested in fgets(). It reads bytes from a file. It ends reading when the specified number of bytes as been read or when a newline is found. Just call it two times and you'll have two lines from your sigs.txt file (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.) Edited December 17, 2003 by TCH-Raul Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.