Нароооооод помогитееееее.
$fw = $w + 8 + $imageMargin * 2 + $borderPad * 2;
if($header) {
$begining = 0;
$trimedtext = trim($header);
do {
$position = strpos($trimedtext,' ');
$writetext.= substr ($trimedtext,$begining, $position);
$trimedtext = substr ($trimedtext,$position + 1);
$haa1 = imagettfbbox($headerSize, 0, $headerFont, $writetext);
$wta1 = $haa1[2]-$haa1[0];
if($wta1 <= $fw){
$ha1 = imagettfbbox($headerSize, 0, $headerFont, $writetext);
}
$writetext.=' ';
}
while(strpos($trimedtext,' ')!==false);
$writetext .= $trimedtext;
}
тут я перенос строи не могу настроить.