• Модуль: intranet
  • Путь к файлу: ~/bitrix/modules/intranet/lib/component/userprofile/stresslevel/img.php
  • Класс: BitrixIntranetComponentUserProfileStressLevelImg
  • Вызов: Img::wordWrapAnnotation
protected function wordWrapAnnotation(&$image, &$draw, $text, $maxWidth)
{
	$factor = $this->factor;

	$words = explode(" ", $text);
	$lines = array();
	$i = 0;
	$lineHeight = 0;
	while($i < count($words) )
	{
		$currentLine = $words[$i];
		if($i+1 >= count($words))
		{
			$lines[] = $currentLine;
			break;
		}
		$metrics = $image->queryFontMetrics($draw, $currentLine . ' ' . $words[$i+1]);
		while($metrics['textWidth'] <= $maxWidth)
		{
			$currentLine .= ' '.$words[++$i];
			if ($i+1 >= count($words))
			{
				break;
			}
			$metrics = $image->queryFontMetrics($draw, $currentLine.' '.$words[$i+1]);
		}

		$lines[] = $currentLine;
		$i++;
		if($metrics['textHeight'] > $lineHeight)
		{
			$lineHeight = $metrics['textHeight'] - $factor*3;
		}
	}
	return [$lines, $lineHeight];
}