protected function wrapTextWithOverflow($text)
{
$lines = array();
// Split text explicitly into lines by \n, \r\n and \r
$explicitLines = preg_split('/\n|\r\n?/', $text);
foreach ($explicitLines as $line) {
// Check every line if it needs to be wrapped
$words = explode(" ", $line);
$line = $words[0];
for ($i = 1; $i < count($words); $i++) {
$box = $this->calculateBox($line." ".$words[$i]);
if ($box->getWidth() >= $this->box->getWidth()) {
$lines[] = $line;
$line = $words[$i];
} else {
$line .= " ".$words[$i];
}
}
$lines[] = $line;
}
return $lines;
}
Перенос работает только с английскими буквами