php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52756 bounding box coordinates are wrong
Submitted: 2010-09-01 04:12 UTC Modified: 2016-10-09 04:22 UTC
Votes:112
Avg. Score:4.7 ± 0.8
Reproduced:88 of 92 (95.7%)
Same Version:52 (59.1%)
Same OS:38 (43.2%)
From: rasmus at mindplay dot dk Assigned: pajoye (profile)
Status: No Feedback Package: GD related
PHP Version: 5.2.14 OS: Linux delphinus 2.6.32.8
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2010-09-01 04:12 UTC] rasmus at mindplay dot dk
Description:
------------
The metrics returned by this function are inaccurate - I put together a comprehensive test script that demonstrates the problem:

http://fontjazz.com/metrics/test.php

This is also reproducible on my workstation with PHP 5.3.1 on Windows Vista SP1 (build 6001).

This bug has been present in Windows builds of PHP 5 for at least a year, and was introduced in Linux builds more recently - my font embedding system (fontjazz.com) is currently generating broken fonts due to this bug.

I've reported this bug before, and if I recall, others reported it before I did - relating this problem to notes/revisions from previous attempts to address this problem might be useful, but I can't seem to find the old bug in the database anymore.

I don't recall if this bug was blamed on PHP, GD or FreeType - I think there were different theories at the time, but it looks like there was no resolution.

Test script:
---------------
The source code for the test script is displayed on this page:

http://fontjazz.com/metrics/test.php

You will need a font for testing - I recommend "georgiai.ttf", the OpenType version, which can be found on Windows Vista installations under WINDOWS\Fonts.

If you don't have this font, try another OpenType font in italics - this problem seems to affect italic fonts the worst, probably because italic typefaces generally have more glyph overlap.

With some non-italic fonts, unless rendered at really large sizes, the problem may not be obvious enough to spot with the eye, but there is always some degree of inaccuracy, with any font, when rendered at a sufficiently large size.


Expected result:
----------------
The red outline should accurately surround the rendered text.

Actual result:
--------------
The red outline is somewhat offset.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-09-01 11:12 UTC] pajoye@php.net
-Status: Open +Status: Feedback
 [2010-09-01 11:12 UTC] pajoye@php.net
Please try with 5.3.3
 [2010-09-01 14:18 UTC] rasmus at mindplay dot dk
No luck with PHP 5.3.3 from the XAMPP distribution on Windows.
 [2010-09-01 15:34 UTC] pajoye@php.net
Please provide the font file you use.
 [2010-09-06 12:51 UTC] pajoye@php.net
-Status: Feedback +Status: Assigned -Assigned To: +Assigned To: pajoye
 [2010-09-08 21:19 UTC] rasmus at mindplay dot dk
For the record, the related bug I posted last year is here:

http://bugs.php.net/bug.php?id=49815
 [2010-09-28 04:41 UTC] rasmus at mindplay dot dk
Any progress? Or is this a low-priority bug? I guess not too many people are 
seriously affected by this.

I'm having to answer a lot of e-mails to explain why fontjazz.com is broken. I 
guess maybe I should take the site off-line for the time being (?)
 [2013-01-01 18:34 UTC] rasmus at mindplay dot dk
Time for my annual update on this bug.

I still get many disappointed e-mails from people complaining that fontjazz.com 
does not work. All I can tell them is, I can't do anything about it, and I don't 
know who can.

Retested and confirmed today with the following releases:

5.3.20 on Windows
5.4.10 on Windows
5.3.13 on Linux

This bug is still very much present on every PHP installation I can get my hands 
on.

I have posted the test-scripts on GitHub here, to make this issue as easy as 
possible to reproduce:

https://gist.github.com/4429153

Maybe we'll see a fix this year? Who knows.

Happy New Year.
 [2013-07-09 16:24 UTC] rasmus at mindplay dot dk
For the record, I chose to let fontjazz.com expire and die this year - this 
issue has been open and remains unaddressed after four years on the record, so I 
give up.

Since the site is dead, the test-script I provided above, which demonstrates the 
issue, has moved here:

http://stuff.mindplay.dk/temp/metrics/test.php

In case you decide to fix the bug someday...
 [2016-01-20 22:47 UTC] daniel at kirschkern dot de
This issue is still reproducable in 7.0.1
Hope to see this fixed soon.
 [2016-07-16 02:08 UTC] cmb@php.net
There is PR #1845 which looks rather promising in this regard, but
there are still issues (platform dependend rounding, different
freetype versions?) Please give it a try, and report back as
detailed as possible.
 [2016-07-16 02:09 UTC] cmb@php.net
Um, the link: <https://github.com/php/php-src/pull/1845>.
 [2016-07-17 19:34 UTC] daniel at kirschkern dot de
Thanks for the hint. I'm very happy to see some progress on this. This will fix a lot of issues for my projects and many workarounds. How can I test it on windows?
 [2016-07-18 14:11 UTC] cmb@php.net
> How can I test it on windows?

There are detailed build instructions available for Windows[1],
but if you haven't set up a build environment, you'd have to
download and install quite some stuff.

An alternative would be to build on Linux in a VM.

[1] <https://wiki.php.net/internals/windows/stepbystepbuild>.
 [2016-09-29 17:44 UTC] cmb@php.net
-Assigned To: pajoye +Assigned To: pajo
 [2016-09-29 17:44 UTC] cmb@php.net
Ah, overlooked this one. In the meantime PR #1845 has been merged,
and is already contained in the latest Windows snapshots on
<http://windows.php.net/downloads/snaps/>.

Please try!
 [2016-09-29 17:44 UTC] cmb@php.net
-Status: Assigned +Status: Feedback -Assigned To: pajo +Assigned To: pajoye
 [2016-10-09 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Jan 19 13:01:24 2021 UTC