【问题标题】:GD error while try load font尝试加载字体时出现 GD 错误
【发布时间】:2013-10-12 08:21:49
【问题描述】:

我尝试通过imageloadfont 函数加载字体。当我运行脚本时,我收到错误:

gd warning: product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully
PHP Warning:  imageloadfont(): Error reading font, invalid font header

什么会导致这个问题?

环境:

Ubuntu 13.04 64 位

PHP 5.4.9-4ubuntu2.3

【问题讨论】:

    标签: php image fonts gd


    【解决方案1】:

    我找到了解决方案。问题不在于 imageloadfont 函数。

    我试图将字体 (.ttf) 加载到 imageloadfont 并将其设置在图像上。我现在没有使用 imagestring 函数,而是使用 imagettftext 来加载自定义字体并将字符串放在图片上。

    【讨论】:

    • 解决办法是不使用bug的功能,而是使用另一个?
    【解决方案2】:

    我在尝试随机使用系统的 .ttf 文件之一时看到了这个错误。 PHP 手册示例有 .gdf 字体文件。

    我的图片尺寸为 1013 x 638(646294 像素),一张身份证大小的图片,分辨率为 300 dpi。

    在我的例子中,PHP_INT_MAX 的值为 2147483647,内存限制设置为 128 MB。

    转换后的新字体文件有效(.gdf 格式字体)

    字体转换器:www.wedwick.com/wftopf.exe

    来源:http://www.animeviews.com/article.php?ID=263

    【讨论】:

      猜你喜欢
      • 2021-07-16
      • 2018-05-03
      • 1970-01-01
      • 2014-07-28
      • 1970-01-01
      • 2023-03-14
      • 2017-08-31
      • 2011-04-02
      • 2017-06-05
      相关资源
      最近更新 更多