duan0514324 2011-06-23 00:39
浏览 515
已采纳

如何在Imagick PHP中设置字体?

I can't seem to get Imagick::setFont to work in php. Taking the example straight from the man page:

/* Create new imagick object */
$im = new Imagick();

/* Set the font for the object */
$im->setFont("comic.ttf");

/* Create new caption */
$im->newPseudoImage(100, 100, "caption:Hello");

$im->setformat('png');
header('Content-type: image/png');
echo $im;

I get...

hellohttp://i53.tinypic.com/2d2bn9x.png

... which is clearly not comic sans. I've tried numerous fonts. It never changes. It does complain if the file doesn't exist. It does not accept names like "Arial".

  • 写回答

2条回答 默认 最新

  • douzhou7656 2012-05-12 11:31
    关注

    I'm having the same situation here and I found this post

    http://www.imagemagick.org/discourse-server/viewtopic.php?f=10&t=11937

    They say Freetype library should be installed, but haven't tried yet.

    UPDATE

    Finally I had chance to try it and It worked.

    I use

    ImageMagick 6.7.6

    Imagick 3.0

    Freetype 2.4.9

    Freetype-devel 2.3.11

    Fontconfig-devel 2.8

    PHP 5.3.13

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?