note 64654 added to function.imagettftext

From: Date: Wed, 19 Apr 2006 13:03:26 +0000
Subject: note 64654 added to function.imagettftext
Groups: php.notes 
Request: Send a blank email to php-notes+get-108606@lists.php.net to get a copy of this message
This is a script that aim at center the (multi) lines : <?php header("Content-type: image/png"); //1line per column $text=array(0=>"line 1",1=>"line 2"); $largeur=500; $line_height=30; $hauteur=sizeof($text)*$line_height; // Create the image $im = imagecreatetruecolor($largeur, $hauteur); // Create some colors $white = imagecolorallocate($im, 255, 255, 255); $grey = imagecolorallocate($im, 225, 225, 225); $blue = imagecolorallocate($im, 0, 62, 126); imagefilledrectangle($im, 0, 0, $largeur, $hauteur, $white); // Replace path by your own font path $font = 'font.ttf'; for($i=0;$i<=sizeof($text);$i++) { //Center the text $size = imagettfbbox(20, 0, $font, $text[$i]); $long_text = $size[2]+$size[0]; $posx=($largeur-$long_text)/2; // Add the text imagettftext($im, 20, 0, $posx, $line_height+$line_height*$i, $blue, $font, $text[$i]); } imagepng($im); imagedestroy($im); ?> ---- Server IP: 217.174.203.10 Probable Submitter: 80.124.144.150 ---- 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/64654 Del: integrated -- http://master.php.net/note/delete/64654/integrated Del: useless -- http://master.php.net/note/delete/64654/useless Del: bad code -- http://master.php.net/note/delete/64654/bad+code Del: spam -- http://master.php.net/note/delete/64654/spam Del: non-english -- http://master.php.net/note/delete/64654/non-english Del: in docs -- http://master.php.net/note/delete/64654/in+docs Del: other reasons-- http://master.php.net/note/delete/64654 Reject -- http://master.php.net/note/reject/64654 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#108606) next »