Inconsistent Results with imagettfbbox
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
Description
The following code (run in a directory containing FreeMono.ttf) gives different results on Linux vs Windows:
<?php
$fontFileName = realpath(__DIR__ . DIRECTORY_SEPARATOR . 'FreeMono.ttf');
var_dump(md5_file($fontFileName)); // to show using same file
var_dump(imagettfbbox(10.0, 0.0, $fontFileName, 'Hello'));
Resulted in this output on Windows:
C:\git\ExactFont\testfont.php:3:
string(32) "ec48e99df5d46035b62ef0d825b43336"
C:\git\ExactFont\testfont.php:4:
array(8) {
[0] =>
int(0)
[1] =>
int(0)
[2] =>
int(39)
[3] =>
int(0)
[4] =>
int(39)
[5] =>
int(-9)
[6] =>
int(0)
[7] =>
int(-9)
}
But I got this output on a Linux Ubuntu system:
C:\git\ExactFont\testfont.php:3:
string(32) "ec48e99df5d46035b62ef0d825b43336"
C:\git\ExactFont\testfont.php:4:
array(8) {
[0] =>
int(0)
[1] =>
int(1)
[2] =>
int(41)
[3] =>
int(1)
[4] =>
int(41)
[5] =>
int(-9)
[6] =>
int(0)
[7] =>
int(-9)
}
PHP Version
7.4.3 and 8.1.8 on Linux; 7.4.26 and 8.0.13 and 8.1.0 on Windows
Operating System
Ubuntu 20.04.4 LTS; Windows 10 Enterprise 19044.1826
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided imagettfbbox example with FreeMono.ttf on the listed Ubuntu and Windows versions, confirming the matching md5_file hash and differing bounding-box arrays. Investigate the platform-specific result and define done as explaining or correcting the discrepancy while preserving the reported reproduction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100