看一下这个ttf文件的位置是否在FONT目录中;另外,写出TTF文件的全路径可能有用。

解决方案 »

  1.   

    to TR@SOE:
    这跟放不放在 Fonts 目录下有什么关系。字体文件跟 PHP 程序放在一起,不用给出全路径。不是路径关系,真要加载不了字体文件会有错误提示的,不要把问题想得这么简单。
      

  2.   


    <?php
    // Set the content-type
    header("Content-type: image/png");// Create the image
    $im = imagecreatetruecolor(400, 30);// Create some colors
    $white = imagecolorallocate($im, 255, 255, 255);
    $grey = imagecolorallocate($im, 128, 128, 128);
    $black = imagecolorallocate($im, 0, 0, 0);
    imagefilledrectangle($im, 0, 0, 399, 29, $white);// The text to draw
    $text = '方正卡通简体...'; 
    // Replace path by your own font path
    $font = '方正卡通简体.ttf';
    $text = iconv('gb2312','utf-8',$text);#Attention
    // Add some shadow to the text
    imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);// Add the text
    imagettftext($im, 20, 0, 10, 20, $black, $font, $text);// Using imagepng() results in clearer text compared with imagejpeg()
    imagepng($im);
    imagedestroy($im);
    ?> 
      

  3.   

    谢谢 SysTem128,我也觉得这个字体比较特殊,用 HTML 代码是可以显示出来的,但是在 PHP 里就不行。我上面的 PHP 代码跟你给出的代码是一样的。谢谢!
      

  4.   

    搜到一片文章(http://soft.yesky.com/tools/239/2022739.shtml),问题解决!可以用 Lucida Sans Unicode 这个字体来显示音标。谢谢各位!