note 68232 added to function.imagettftext

From: Date: Wed, 19 Jul 2006 03:48:58 +0000
Subject: note 68232 added to function.imagettftext
Groups: php.notes 
Request: Send a blank email to php-notes+get-114908@lists.php.net to get a copy of this message
Quick tip for anyone who is receiving text like in the example in this page (ie: through $_GET['text'] or something similar) and needs to format the text into multiple lines. The trick is finding the spaces... <?php $text = $_GET['text']; // for a maximum of 38 characters on a line... while(strlen($text) > 38) { $startPoint = 37; // find a space to break the line on while(substr($text, $startPoint, 1) != " ") { $startPoint--; } $line[] = trim(substr($text, 0, $startPoint)); $text = substr($text, $startPoint); } $line[] = trim($text); ?> The result is an array called $line that contains all the lines of text you need to output in order. The only tasks left are to determine the correct height of the image based on the font size you want to use. Don't forget to leave some padding space for punctuation and descenders between lines (commas, g, q, p, y, etc). imagettftext is unbelievably useful when you need to create header images using non-standard fonts. Amazing. Huge thanks to the devs. --Julian ---- Server IP: 216.235.15.211 Probable Submitter: 72.136.198.163 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.imagettftext.php Edit -- http://master.php.net/note/edit/68232 Del: integrated -- http://master.php.net/note/delete/68232/integrated Del: useless -- http://master.php.net/note/delete/68232/useless Del: bad code -- http://master.php.net/note/delete/68232/bad+code Del: spam -- http://master.php.net/note/delete/68232/spam Del: non-english -- http://master.php.net/note/delete/68232/non-english Del: in docs -- http://master.php.net/note/delete/68232/in+docs Del: other reasons-- http://master.php.net/note/delete/68232 Reject -- http://master.php.net/note/reject/68232 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#114908) next »