note 61785 deleted from function.imagettfbbox by cmb

From: Date: Sun, 07 Jul 2019 08:04:46 +0000
Subject: note 61785 deleted from function.imagettfbbox by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-211508@lists.php.net to get a copy of this message
Note Submitter: greg at gregoryfenton dot be ---- Have a problem with imagettfbbox cutting off the hang of letters such as 'g' or 'j'?? After days trying to figure this thing out, I finally cracked it: $size = imagettfbbox($s,0,$font,$text); $dx=abs($size[0])+abs($size[2]); $dy=abs($size[1])+abs($size[7]); ImageTTFText($im, $s, 0, $dx-abs($size[0]), $dy-abs($size[1]), $black, $font, $text); The key is the abs commands - you must account for the negative numbers in the original imagettfbbox, and if you have any, take them away from the location at the end when the text is displayed: you need to start the x and y at a (possibly) negative number, not 0,0 as I had thought. Hope that helps someone..

« previous php.notes (#211508) next »