note 100184 added to function.imagettftext

From: Date: Wed, 29 Sep 2010 22:46:29 +0000
Subject: note 100184 added to function.imagettftext
Groups: php.notes 
Request: Send a blank email to php-notes+get-172827@lists.php.net to get a copy of this message
If you get letters cut off (clipped) by adjacent letters when using imagettftext with transparency (i.e., imagealphablending set to false), try setting imagealphablending back to TRUE before calling the imagettftext function. <?php $im = imagecreatetruecolor(300, 300); imagealphablending($im, false); imagesavealpha($im, true); // Create colors and draw transparent background $trans = imagecolorallocatealpha($im, 255, 255, 255, 127); $black = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 299, 299, $trans); // Bad text imagettftext($im, 22, 0, 50, 100, $black, 'arial.ttf', 'Bad: Oj Pj wj'); // Good text imagealphablending($im, true); imagettftext($im, 22, 0, 50, 150, $black, 'arial.ttf', 'Good: Oj Pj wj'); /*** You'll need a copy of the arial.ttf font file in the same location as the PHP script ***/ // Output PNG header("Content-type: image/png"); imagepng($im); imagedestroy($im); ?> ---- Server IP: 69.147.83.197 Probable Submitter: 63.248.41.231 ---- Manual Page -- http://www.php.net/manual/en/function.imagettftext.php Edit -- https://master.php.net/note/edit/100184 Del: integrated -- https://master.php.net/note/delete/100184/integrated Del: useless -- https://master.php.net/note/delete/100184/useless Del: bad code -- https://master.php.net/note/delete/100184/bad+code Del: spam -- https://master.php.net/note/delete/100184/spam Del: non-english -- https://master.php.net/note/delete/100184/non-english Del: in docs -- https://master.php.net/note/delete/100184/in+docs Del: other reasons-- https://master.php.net/note/delete/100184 Reject -- https://master.php.net/note/reject/100184 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#172827) next »