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

如何在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条)

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?