public static function render($image, $text, $fFile, array $params = array())
{
// Set vars
$params = array_merge(self::$_default, $params);
$angle = Helper::rotate($params['angle']);
$position = Helper::position($params['position']);
$fSize = $params['font-size'];
$color = $params['color'];
$offsetX = $params['offset-x'];
$offsetY = $params['offset-y'];
$strokeColor = $params['stroke-color'];
$strokeSize = $params['stroke-size'];
$strokeSpacing = $params['stroke-spacing'];
$imageWidth = imagesx($image);
$imageHeight = imagesy($image);
$colorArr = self::_getColor($image, $color);
list($textWidth, $textHeight) = self::_getTextboxSize($fSize, $angle, $fFile, $text);
list($textX, $textY) = Helper::getInnerCoords($position, array($imageWidth, $imageHeight), array($textWidth, $textHeight), array($offsetX, $offsetY));
if ($strokeColor && $strokeSize) {
if (is_array($color) || is_array($strokeColor)) {
// Multi colored text and/or multi colored stroke
$strokeColor = self::_getColor($image, $strokeColor);
$chars = str_split($text, 1);
foreach ($chars as $key => $char) {
if ($key > 0) {
$textX = self::_getStrokeX($fSize, $angle, $fFile, $chars, $key, $strokeSpacing, $textX);
}
// If the next letter is empty, we just move forward to the next letter
if ($char === ' ') {
continue;
}
self::_renderStroke($image, $char, array($fFile, $fSize, current($colorArr), $angle), array($textX, $textY), array($strokeSize, current($strokeColor)));
// #000 is 0, black will reset the array so we write it this way
if (next($colorArr) === false) {
reset($colorArr);
}
// #000 is 0, black will reset the array so we write it this way
if (next($strokeColor) === false) {
reset($strokeColor);
}
}
} else {
$rgba = Helper::normalizeColor($strokeColor);
$strokeColor = imagecolorallocatealpha($image, $rgba[0], $rgba[1], $rgba[2], $rgba[3]);
self::_renderStroke($image, $text, array($fFile, $fSize, current($colorArr), $angle), array($textX, $textY), array($strokeSize, $strokeColor));
}
} else {
if (is_array($color)) {
// Multi colored text
$chars = str_split($text, 1);
foreach ($chars as $key => $char) {
if ($key > 0) {
$textX = self::_getStrokeX($fSize, $angle, $fFile, $chars, $key, $strokeSpacing, $textX);
}
// If the next letter is empty, we just move forward to the next letter
if ($char === ' ') {
continue;
}
$fontInfo = array($fFile, $fSize, current($colorArr), $angle);
self::_render($image, $char, $fontInfo, array($textX, $textY));
// #000 is 0, black will reset the array so we write it this way
if (next($colorArr) === false) {
reset($colorArr);
}
}
} else {
self::_render($image, $text, array($fFile, $fSize, $colorArr[0], $angle), array($textX, $textY));
}
}
}