imagettfbbox():无效的字体文件名

时间:2011-08-06 17:59:09

标签: php image image-processing

<?php
$size = 12;//font height
$font = 'Arial';// your font
$char = 'Test';
$char = 'With W';
$char = 'without w but with p and y and q';

    $rect = imagettfbbox($size, 0, $font, $char);

    $image_height =abs( $rect[7] );//do no respect bottom margin
    $imw = $rect[2] - $rect[0]; //as usual
    $bx = abs( $rect[ 0 ] ); // X offset 
    $by = $size * 1.25; // Y offset - we will use const LINEHEIGHT
?>

你能帮我解决这个错误吗?

警告:imagettfbbox()[function.imagettfbbox]:第8行的C:\ wamp \ www \ test \ createImage.php中的字体文件名无效

3 个答案:

答案 0 :(得分:2)

font参数应该是.ttf文件,而不是字体名称。您可以通过快速谷歌搜索找到fonts的大量资源。

https://secure.php.net/manual/en/function.imagettfbbox.php

答案 1 :(得分:0)

使用时对我有用:

$font = './arial.ttf';

从以下位置复制arial文件后 php文件所在的目录的“ (C:/Windows/)fonts”。

答案 2 :(得分:-1)

小心路径。如果您使用pChart,示例可以正常工作,但由于字体文件的路径,您的文件不起作用。

因此,您必须将../替换为空白。

示例: ../fonts/Forgotte.ttf fonts/Forgotte.ttf。对我来说它有效

相关问题