I have noticed that when using 'imagettfbbox' it seems to be far from accurate. For example:
<?php
$text = 'hello there';
$box = imagettfbbox(12,0,'arial.ttf',$text);
$width = abs($box[0]-$box[2]);
$text = str_replace(' ',' ',$text);
echo '<svg width="500" height="200">
<g transform="scale(5)">
<text x="0" y="20" style="font-family:arial; font-size:12pt;">'.$text.'</text>
<rect x="0" y="10" width="'.$width.'" height="20" style="fill-opacity:0.5; fill:yellow;" />
</g>
</svg>';
exit;
?>
As you can see here, the box almost completely cuts off the 'e'. Is there any other solution to getting an accurate box width?