• Модуль: intranet
  • Путь к файлу: ~/bitrix/modules/intranet/lib/component/userprofile/stresslevel/img.php
  • Класс: BitrixIntranetComponentUserProfileStressLevelImg
  • Вызов: Img::drawImageComment
protected function drawImageComment(array $params = [])
{
	$text = (
		isset($params['value'])
			? $params['value']
			: false
	);
	$canvas = (
		isset($params['canvas'])
			? $params['canvas']
			: false
	);
	$factor = $this->factor;

	if (
		!$text
		|| !$canvas
		|| $text == ''
	)
	{
		return false;
	}

	$textComment = new ImagickDraw();
	$fontPath = $this->getImagePartsPath().'/OpenSans-Light.ttf';
	if (!file_exists($fontPath))
	{
		return false;
	}
	$fontSize = 16;
	$textComment->setFont($fontPath);
	$textComment->setFillColor('#333333');
	$textComment->setStrokeAntialias(true);
	$textComment->setTextAntialias(true);
	$textComment->setFontSize($factor*$fontSize);
	$textComment->setTextAlignment(Imagick::ALIGN_LEFT);

	$error = "";
	if (LANG_CHARSET != "UTF-8")
	{
		$text = BitrixMainTextEncoding::convertEncoding($text, LANG_CHARSET, "UTF-8", $error);
		if (
			!$text
			&& !empty($error)
		)
		{
			$this->errorCollection[] = new Error('CONVERT_CHARSET_ERROR');
			return null;
		}
	}


	list($lines, $lineHeight) = self::wordWrapAnnotation($canvas, $textComment, $text, $factor*154);
	$linesCount = count($lines);

	while($linesCount > 2)
	{
		$fontSize--;
		$textComment->setFontSize($factor*$fontSize);
		list($lines, $lineHeight) = self::wordWrapAnnotation($canvas, $textComment, $text, $factor*154);
		$linesCount = count($lines);
	}

	for($i = 0; $i < $linesCount; $i++)
	{
		$canvas->annotateImage($textComment, $factor*152, $factor*58 + $i*$lineHeight, 0, $lines[$i]);
	}

	return true;
}