Пример #1
0
 public function text($text, $color, $size, $font = 'FetteSteinschrift')
 {
     $font = BASE . "vendor/captcha/fonts/en/" . $font . ".ttf";
     $draw = new \ImagickDraw();
     $draw->setGravity(\Imagick::GRAVITY_CENTER);
     $draw->setFont($font);
     $draw->setFontSize($size);
     $draw->setFillColor(new \ImagickPixel($color));
     $im = new \imagick();
     $properties = $im->queryFontMetrics($draw, $text);
     $im->newImage(intval($properties['textWidth'] + 5), intval($properties['textHeight'] + 5), new \ImagickPixel('transparent'));
     $im->setImageFormat('png');
     $im->annotateImage($draw, 0, 0, 0, $text);
     return $im;
 }
        break;
    case 24:
        $titleWordwrap = 21;
        break;
    case 26:
        $titleWordwrap = 19;
        break;
    case 28:
        $titleWordwrap = 17;
        break;
    case 30:
        $titleWordwrap = 16;
        break;
}
$fixedCardTitle = wordwrap($cardTitle, $titleWordwrap, "\n");
$b->annotateImage($draw1, 340, 50, 0, $fixedCardTitle);
/* Draw Message */
$draw2 = new ImagickDraw();
/* Text Color */
$draw2->setFillColor($messageColor);
/* Font properties */
$draw2->setFont($messageFont);
$draw2->setFontSize($messageSize);
$draw2->setFontWeight(400);
// change wordwrap depending on font size
switch ($messageSize) {
    case 20:
        $messageWordwrap = 24;
        break;
    case 22:
        $messageWordwrap = 23;