I just wrote some code and tested it. and it runs quite fine. see if this works for you or not.
It create a transparent text box and start writing things on it.
It does not include the angle function yet

It create a transparent text box and start writing things on it.
It does not include the angle function yet
| Code: |
|
function imagewordwrap($image,$x,$y,$w,$h,$text,$font,$color,$size=10,$dial='-'){ $cool = imagettfbbox ($size, 0, $font, 'A'); $line_height = $cool[1]-$cool[7]; $textarea = imagecreatetruecolor($w,$h); $base = imagecreatefromstring(base64_decode('iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAADqSURBVHjaYvz//z/DYAYAAcTEMMgBQAANegcCBNCgdyBAAA16BwIE0KB3IEAADXoHAgTQoHcgQAANegcCBNCgdyBAAA16BwIE0KB3IEAADXoHAgTQoHcgQAANegcCBNCgdyBAAA16BwIE0KB3IEAADXoHAgTQoHcgQAANegcCBNCgdyBAAA16BwIE0KB3IEAADXoHAgTQoHcgQAANegcCBNCgdyBAAA16BwIE0KB3IEAADXoHAgTQoHcgQAANegcCBNCgdyBAAA16BwIE0KB3IEAADXoHAgTQoHcgQAANegcCBNCgdyBAgAEAMpcDTTQWJVEAAAAASUVORK5CYII=')); imagealphablending($textarea,false); imagesavealpha($textarea,true); imagecopyresized($textarea,$base,0,0,0,0,$w,$h,imagesx($base),imagesy($base)); $word = explode(' ',$text); $count = count($word); $n = 0; $tmp =''; $real=''; while($n<$count){ $a = imagettfbbox($size, 0, $font, $tmp.' '.$word[$n]); if($a[2]-$a[0]<=$w){ $tmp .= $word[$n].' '; }else{ $a = imagettfbbox($size,0,$font, $word[$n]); if($a[2] - $a[0]<=$w){ $real .= $tmp."\n"; $tmp = $word[$n]; }else{ $k = 0; $c = strlen($word[$n]); while($k<$c){ $a = imagettfbbox($size, 0, $font, $tmp.' '.$word[$n][$k].$dial); if($a[2]-$a[0]<=$w){ $tmp .= ' '.$word[$n][$k]; }else{ if($k !=0){ $real .= "\n".$tmp.$dial; $tmp = ''; } } ++$k; } } } ++$n; } $real .= $tmp; imagettftext($textarea, $size, 0, 0, $line_height, $color, 'C2C_faded.ttf', $real); imagecopy($image, $textarea, $x, $y, 0, 0, $w, $h); } |
