php / php/php-src

Inconsistent Results with imagettfbbox

未关闭
#9,073 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Bug Extension: gd Status: Needs Triage
主要语言
C
星标
40.4k
派生
8.2k
平均合并
2 天 13 小时
30 天内合并 PR
96

描述

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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先,在列出的 Ubuntu 和 Windows 版本上使用 FreeMono.ttf 运行所提供的 imagettfbbox 示例,确认匹配的 md5_file 哈希值以及不同的边界框数组。调查平台特定的结果,并将解释或纠正该差异同时保留所报告的复现定义为完成(done)。

由索引模型根据 Issue 内容生成。

评估

技术栈
php
领域
computer-graphics
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。