note 114301 added to imagick.queryfontmetrics

From: Date: Tue, 04 Feb 2014 17:34:23 +0000
Subject: note 114301 added to imagick.queryfontmetrics
Groups: php.notes 
Request: Send a blank email to php-notes+get-198408@lists.php.net to get a copy of this message
The values do not match the array descriptors at all. If you have to know exactly how much space is being taken up by an annotation, use the following: <?php $text = "Algbqdj"; $im = new Imagick (); $draw = new ImagickDraw (); $draw->setStrokeColor ("none"); $draw->setFont ("Arial"); $draw->setFontSize (96); $draw->setTextAlignment (Imagick::ALIGN_LEFT); $metrics = $im->queryFontMetrics ($draw, $text); //these are the values which accurately described the extent of the text and where it is to be drawn: $baseline = $metrics['boundingBox']['y2']; $textwidth = $metrics['textWidth'] + 2 * $metrics['boundingBox']['x1']; $textheight = $metrics['textHeight'] + $metrics['descender']; $draw->annotation (0, $baseline, $text); $im->newImage ($textwidth, $textheight, "white"); $im->drawImage ($draw); $draw->clear (); $im->writeImage ("test.png"); $im->clear (); ?> The file test.png should now contain pretty much the complete text with no borders. This may not work for very unusual fonts, but will work OK for Times New Roman and Arial. ---- Server IP: 213.172.110.14 Probable Submitter: 89.182.58.142 ---- Manual Page -- http://php.net/manual/en/imagick.queryfontmetrics.php Edit -- https://master.php.net/note/edit/114301 Del: integrated -- https://master.php.net/note/delete/114301/integrated Del: useless -- https://master.php.net/note/delete/114301/useless Del: bad code -- https://master.php.net/note/delete/114301/bad+code Del: spam -- https://master.php.net/note/delete/114301/spam Del: non-english -- https://master.php.net/note/delete/114301/non-english Del: in docs -- https://master.php.net/note/delete/114301/in+docs Del: other reasons-- https://master.php.net/note/delete/114301 Reject -- https://master.php.net/note/reject/114301 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#198408) next »