<?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。: C:'wamp'www'test'createImage.php第8行中字体文件名无效
font参数应该是.ttf文件,而不是字体名称。你可以通过谷歌搜索找到很多关于字体的资源。
https://secure.php.net/manual/en/function.imagettfbbox.php使用
$font = './arial.ttf';
后,我复制的arial文件
(C:/Windows/)fonts
"移至php文件所在目录。小心路径。如果你使用pChart的例子工作,但你的文件不能工作,因为字体文件的路径。
因此必须将../
替换为blank
示例: ../fonts/Forgotte.ttf
with fonts/Forgotte.ttf
。