本文介绍了如何在imagemagick中包装文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我能够像这样想出一个基本的自动换行功能
I was able to figure a basic word wrap function like this
$draw = new ImagickDraw();
$x = 0;
$y=20;
$angle = 0;
$str = "some text for testing of a word wrap in imagemagick";
$str = wordwrap($str, 10,"\r");
$im->annotateImage( $draw, $x, $y, $angle, $str );
这似乎工作正常,除了跟踪我认为它叫你知道线之间的空间是太多关于如何解决这个问题的想法或想法,或者是否有更好的选择
and that seems to work ok except that the tracking i think its called you know the space between lines is too much and thoughts or ideas on how to fix this or if there is a better option
推荐答案
正弦我可以控制间距我去渲染线条每个
Sine I could control the spacing I went with rendering the lines each
$draw = new ImagickDraw();
$x = 0;
$y=20;
$angle = 0;
$padding = 10;
$str = "some text for testing of a word wrap in imagemagick";
$str = wordwrap($str, 10,"\r");
$str_array = explode("\n",$str);
foreach($str_array as $line)
$im->annotateImage( $draw, $x, $y+$padding, $angle, $line );
}
这篇关于如何在imagemagick中包装文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!