php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48155 imagettftext() and imagefttext() do not accurately position text horizontally
Submitted: 2009-05-05 18:22 UTC Modified: 2009-08-28 01:00 UTC
Votes:4
Avg. Score:4.5 ± 0.5
Reproduced:4 of 4 (100.0%)
Same Version:1 (25.0%)
Same OS:1 (25.0%)
From: tom at streamsense dot net Assigned:
Status: No Feedback Package: GD related
PHP Version: 5.*, 6CVS (2009-05-05) OS: *
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2009-05-05 18:22 UTC] tom at streamsense dot net
Description:
------------
Whilst PHP can very accurately get the bounding box of TTF text, when drawing it does not position the text accurately on the X axis.

The error margin varies depending on the glyphs being drawn.

System 	Windows NT S15289149 6.0 build 6001 (Windows Server 2008)
PHP Version 5.2.9-2
Build Date 	Apr 9 2009 08:22:37 
GD Version 	bundled (2.0.34 compatible) 
FreeType Version 	2.1.9 

Reproduce code:
---------------
http://www.pastebin.ca/1413488

Expected result:
----------------
All text should be contained within the red bounding box.

Actual result:
--------------
http://bayimg.com/image/dapmiaabh.jpg

Text is not contained with the indicated red bounding boxes.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-05-05 19:28 UTC] pajoye@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2009-05-05 19:36 UTC] tom at streamsense dot net
Confirmed reproducable on PHP Version 5.3.0RC2-dev

GD Version 	bundled (2.0.34 compatible) 
FreeType Version 	2.3.9
 [2009-05-05 19:39 UTC] pajoye@php.net
Please post a link to the font you use.
 [2009-05-05 19:47 UTC] tom at streamsense dot net
The font is arial black, included with any windows install, but this is totally reproducable with any font (or at least all i've tried). I've tried tahoma, arial, arial black, times new roman.
 [2009-06-15 15:49 UTC] a dot schilder at gmx dot net
Same problem with PHP 5.3RC3 on Windows XP
 [2009-08-20 19:21 UTC] aaustin at smartypig dot com
I'm not a PHP developer, but using FaceLift (http://facelift.mawhorter.net) we've run into a bunch of different bugs relating to bounding box / position calculation of TTF fonts.  All have been fixed in the latest snapshot except the horizontal/x position of the output.

It seems like the image generated is always a few pixels shifted left, depending on the font and size of the font, but all are reproduceable.

(http://forums.mawhorter.net/viewtopic.php?id=458)
 [2009-08-20 20:22 UTC] pajoye@php.net
Yes, I think all issues related to this one has been fixed. Do you have a script to reproduce the horizontal shift? We also need to know which freetype version you are using.
 [2009-08-28 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 09 16:01:31 2024 UTC