|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71602 bounding box not accurate
Submitted: 2016-02-15 22:22 UTC Modified: 2016-02-24 00:00 UTC
From: treboralmasy1 at gmail dot com Assigned: cmb (profile)
Status: Duplicate Package: GD related
PHP Version: 5.6.18 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: treboralmasy1 at gmail dot com
New email:
PHP Version: OS:


 [2016-02-15 22:22 UTC] treboralmasy1 at gmail dot com
From manual page:

The bounding box dimensions are not accurate sometimes being off by as much as a full character.

Test script:
$text = 'hello there';
$box = imagettfbbox(12,0,'arial.ttf',$text);
$width = abs($box[0]-$box[2]);
$text = str_replace(' ','&nbsp;',$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;" />



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-02-16 11:32 UTC]
-Package: *General Issues +Package: GD related
 [2016-02-23 12:43 UTC]
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2016-02-23 12:43 UTC]
Duplicate of bug #53504.
 [2016-02-24 00:00 UTC] treboralmasy1 at gmail dot com
So this has been a known bug for 6 years?
 [2016-03-31 11:36 UTC] mplomer at gmx dot de
For proposed fix and further info/discussion, see bug #53504
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Feb 28 12:01:27 2024 UTC