List Info

Thread: note 68518 added to function.imagettfbbox




note 68518 added to function.imagettfbbox
user name
2006-07-31 13:13:00
Please note that as imageTTFBbox and imageTTFText functions
return an array of coordinates which could be negative
numbers care must be taken with height and width
calculations.

The rigth way to do that is to use the abs() function:

for an horizontal text:

$box = imageTTFBbox($size,0,$font,$text);
$width = abs($box[4] - $box[0]);
$height = abs($box[5] - $box[1]);

Then to center your text at ($x,$y) position the code should
be like that:

$x -= $width/2;
$y += $heigth/2;

imageTTFText($img,$size,0,$x,$y,$color,$font,$text);

this because (0,0) page origin is topleft page corner and
(0,0) text origin is lower-left readable text corner.

Hope this help.
----
Server IP: 195.221.21.36
Probable Submitter: 164.129.1.39 (proxied: unknown, unknown)
----
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.imagettfbbox.php
Edit        -- https://master
.php.net/note/edit/68518
Del: integrated  -- h
ttps://master.php.net/note/delete/68518/integrated
Del: useless     -- http
s://master.php.net/note/delete/68518/useless
Del: bad code    -- htt
ps://master.php.net/note/delete/68518/bad+code
Del: spam        -- https:/
/master.php.net/note/delete/68518/spam
Del: non-english -- 
https://master.php.net/note/delete/68518/non-english
Del: in docs     -- http
s://master.php.net/note/delete/68518/in+docs
Del: other reasons-- https://mast
er.php.net/note/delete/68518
Reject      -- https://mast
er.php.net/note/reject/68518
Search      -- https://
master.php.net/manage/user-notes.php

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )