首页 > imagemagic设置字体问题

imagemagic设置字体问题

虚拟机中我已安装imagick组件,以及要用到的字体。
如图:

imagick画图部分代码如下:


$imagick = new Imagick($template_image);
$draw = new ImagickDraw();
$draw->setFillColor('black');
$draw->setFont('/usr/share/fonts/wqy-microhei.ttc');
$draw->settextencoding('utf-8');
$draw->setFontSize(30);
imagick_add_text($imagick,$draw,"测试", 302, 688, 130,'#33BAF6');

写字函数:

function imagick_add_text(&$imagick, &$draw, $text, $x = 0, $y = 0, $font_size = 12, $fill_color = 0, $text_kerning = 0) {
    if (isset($font_size))
        $draw->setFontSize($font_size);
    if (isset($fill_color))
        $draw->setFillColor($fill_color);
    if (isset($text_kerning))
        $draw->setTextKerning($text_kerning);
    $imagick->annotateImage($draw, $x, $y, 0, $text);
}

现在的问题是,$draw->setFont()这一步是没有报错的,说明字体设置成功了,但是$imagick->annotateImage() 也就是画图这一步出错了。
为什么,是字体问题吗?

注:
1.我使用的是vagrant虚拟环境进行开发。
2.测试环境中安装了相同的字体,并且使用imagick画图写字成功。(测试环境字体是运维人员装的)

【热门文章】
【热门文章】