PHP Imagick - setTextEncoding()函数不起作用 [英] PHP Imagick - setTextEncoding() function doesn't work

查看:189
本文介绍了PHP Imagick - setTextEncoding()函数不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



但是我使用setTextEncoding()函数,它仍然不起作用。

  ....... 

$ draw = new ImagickDraw();
$ draw-> setTextEncoding('utf-8');
$ draw-> setFont($ fpath。'/ process / ARIAL.TTF');
$ draw-> setFontSize(80);
$ draw-> setFillColor(#ffffff);

/ ***注释图像上的文字*** /
$ imageOrg-> annotateImage($ draw,60,100,0,onurküçükkeçe);

........

因此我get,

  onurküçükkeçe

任何想法为什么不起作用?



提前感谢



更新



如果我将一个$文本变量设置为chr(252),那么我得到一个正确的结果

  $ text = chr(252); 
$ imageOrg-> annotateImage($ draw,60,100,0,$ text);

因此我得到

 ü

更新II



最后我发现导致这种情况。



出现此问题是因为文档的字符集未定义,但如果设置为脚本的字符集,然后imagick不起作用,因为文档的类型需要设置为image / png。



但是我不知道如何解决

解决方案

好的。我找到了解决方案。



php utf8_decode()功能解决问题

  ....... 

$ draw = new ImagickDraw();
$ draw-> setTextEncoding('utf-8');
$ draw-> setFont($ fpath。'/ process / ARIAL.TTF');
$ draw-> setFontSize(80);
$ draw-> setFillColor(#ffffff);

/ ***注释图像上的文字*** /
$ imageOrg-> annotateImage($ draw,60,100,0,utf8_decode(onurküçükkeçe)) ;

........


I'm trying to add some text on a Imagick object.

However I use setTextEncoding() function, it still doesn't work.

.......

$draw = new ImagickDraw();
$draw->setTextEncoding('utf-8');
$draw->setFont($fpath.'/process/ARIAL.TTF'); 
$draw->setFontSize(80);
$draw->setFillColor("#ffffff");

/*** annotate the text on the image ***/
$imageOrg->annotateImage($draw, 60, 100, 0, "onur küçükkeçe");

........

and as a result I get,

onur küçükkeçe

Any idea why it's not working?

Thanks in advance.

UPDATE

if I set a $text variable to something like chr(252) then I get a proper result

$text=chr(252);
$imageOrg->annotateImage($draw, 60, 100, 0, $text);

as a result I get

ü

UPDATE II

Finally I found what causing this.

The problem occurs because the charset of the document is not defined but if set a charset for the script then imagick doesn't work because the type of the document needs to be set to image/png.

But I don't know how can I fix it.

解决方案

Ok. I found the solution.

php utf8_decode() function solves the problem

.......

$draw = new ImagickDraw();
$draw->setTextEncoding('utf-8');
$draw->setFont($fpath.'/process/ARIAL.TTF'); 
$draw->setFontSize(80);
$draw->setFillColor("#ffffff");

/*** annotate the text on the image ***/
$imageOrg->annotateImage($draw, 60, 100, 0, utf8_decode("onur küçükkeçe"));

........

这篇关于PHP Imagick - setTextEncoding()函数不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆