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

	if (
		!$canvas
		|| !$center
	)
	{
		return false;
	}

	$imageCaption = new ImagickDraw();
	$fontPath = $this->getImagePartsPath().'/OpenSans-Semibold.ttf';
	if (!file_exists($fontPath))
	{
		return false;
	}
	$imageCaption->setFont($fontPath);
	$imageCaption->setFillColor('#525c69');
	$imageCaption->setFillOpacity(0.7);
	$imageCaption->setStrokeAntialias(true);
	$imageCaption->setTextAntialias(true);
	$imageCaption->setFontSize($factor*8);
	$imageCaption->setTextAlignment(Imagick::ALIGN_CENTER);

	$caption = mb_strtoupper(Loc::getMessage('INTRANET_USER_PROFILE_STRESSLEVEL_IMG_VALUE_CAPTION'));
	if ($caption == '')
	{
		return false;
	}

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

	$imageCaption->annotation($center['x'], $center['y']-$factor*13, $caption);
	$canvas->drawImage($imageCaption);

	return true;
}