Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 有人知道为什么imagettftext不';不要打开字体文件_Php_Imagettftext_Bonfire - Fatal编程技术网

Php 有人知道为什么imagettftext不';不要打开字体文件

Php 有人知道为什么imagettftext不';不要打开字体文件,php,imagettftext,bonfire,Php,Imagettftext,Bonfire,我正在尝试使用我在网站上上传的字体,但我一直遇到以下错误: “imagettftext():无法找到/打开字体” 我已经尝试使用putenv工具,但它仍然没有打开文件。篝火上是否有一个选项限制可以使用的文件类型? 我可以使用imagestring函数,但我想使用其他字体 我能够将字体加载到HTML文件中,因此它似乎与imagettftext()有关 GD/FreeType字体加载代码仅限于本地文件系统。您的代码正在尝试从HTTP URL读取字体: $font = array(... 'fi

我正在尝试使用我在网站上上传的字体,但我一直遇到以下错误:

imagettftext()
:无法找到/打开字体”

我已经尝试使用putenv工具,但它仍然没有打开文件。篝火上是否有一个选项限制可以使用的文件类型? 我可以使用imagestring函数,但我想使用其他字体

我能够将字体加载到HTML文件中,因此它似乎与
imagettftext()
有关


GD/FreeType字体加载代码仅限于本地文件系统。您的代码正在尝试从HTTP URL读取字体:

$font = array(...
   'file'=>'https://dev3.successengineapps.com/fonts/DIGITALDREAM.ttf'
...);
GD中的字体加载代码不知道如何发出HTTP请求

下面是获得某种输出所需的最小代码集的示例;也就是说,我没有试图以任何方式对您的代码进行认真的重写,但也删除了与问题没有明显直接关系的内容:

<?php
header('Content-Type: image/gif');
$image = imagecreatefrompng('https://dev3.successengineapps.com/themes/admin/images/countdown.png');
    $font = array(
        'size'=>40,
        'angle'=>0,
        'x-offset'=>10,
        'y-offset'=>70,
        'file'=>'./DIGITALDREAM.ttf',
        'color'=>imagecolorallocate($image, 255, 255, 255),
    );
$text = "Hello, world.";
if (imagettftext ($image , $font['size'] , $font['angle'] , $font['x-offset'] , $font['y-offset'] , $font['color'],$font['file'] ,$text)) {
        imagegif($image);
} else {
        var_dump($php_errormsg);
}

尝试使用完整路径。或者查看
echo getcwd()的输出。它是否与.ttf文件所在的位置相同?否.ttf文件与我的php位于同一目录中。我已经在几个地方放了一份.ttf文件的副本,包括具有正确路径的public_html文件夹,但它仍然给我带来问题。我可以打开指向路径的url,它会提示我下载文件。我甚至尝试在另一台服务器上使用URL,效果很好。我认为这个问题与imagettftext()有关,因为imageString函数工作正常,我只想使用.ttf文件数组([GD版本]=>bundle(2.0.34兼容)[FreeType支持]=>1[FreeType链接]=>with FreeType[T1Lib支持]=>[GIF读取支持]=>1[GIF创建支持]=>1[JPEG支持]=>1[PNG支持]=>1[WBMP支持]=>1[XPM支持]=>1[XBM支持]=>1[JIS映射日语字体支持]=>)我知道-打开/加载TTF文件的代码不使用PHP的
流,而是使用FreeType,它不支持URL,仅本地文件系统。我当前正在尝试一个路径,但该路径也不起作用(/home/dev3/public_html/fonts/DIGITALDREAM.ttf)。您应该改进您的问题,在另一台服务器上问“有人知道imagettftext在使用URL打开文件时会遇到问题吗?”,通过添加GDfontpath并仅使用文件名(无路径),我的代码与引用的文件几乎相同,这导致了这个问题。我在与.php文件相同的目录中有一个副本,但这也不起作用。。。
<?php
header('Content-Type: image/gif');
$image = imagecreatefrompng('https://dev3.successengineapps.com/themes/admin/images/countdown.png');
    $font = array(
        'size'=>40,
        'angle'=>0,
        'x-offset'=>10,
        'y-offset'=>70,
        'file'=>'./DIGITALDREAM.ttf',
        'color'=>imagecolorallocate($image, 255, 255, 255),
    );
$text = "Hello, world.";
if (imagettftext ($image , $font['size'] , $font['angle'] , $font['x-offset'] , $font['y-offset'] , $font['color'],$font['file'] ,$text)) {
        imagegif($image);
} else {
        var_dump($php_errormsg);
}