note 62428 deleted from function.imagettfbbox by cmb
| From: | cmb@php.net | Date: | Sun, 17 Nov 2019 08:54:05 +0000 |
| Subject: | note 62428 deleted from function.imagettfbbox by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-213091@lists.php.net to get a copy of this message | ||
Note Submitter: toe dot cutter at telia dot com
----
Neither Greg's or Henrik N's code worked for me.
I figured out that imagettfbbox gives the size (coordinates) of the whole letter (ie. with the hang
on 'g' or 'j'). So it was only a matter of finding the correct index of
coordinates in the array.
Note: This doesn't work on Times New Roman Italic's 'f' for some reason.
<?php
$size = imagettfbbox($fontsize, 0, $font, $text);
$dx = abs($size[2]-$size[0]);
$dy = abs($size[5]-$size[3]);
ImageTTFText($im, $fontsize, 0, abs($size[6]), abs($size[5]), $txtcolor, $font, $text);
?>