Skip to content

Inconsistent Results with imagettfbbox #9073

@oleibman

Description

@oleibman

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions