The following snippet works fine other than the setFontWeight part.
Code: Select all
<?php
// Set the base variables and get any that have been passed in
$textColor = "#000000";
$fontSize = 20;
$line1 = "Example";
$strFont = "fonts/MyriadPro-Bold.otf";
// Generate the images used to compose the template
$imgButtonText = new Imagick();
//Create new draw instance and set up the font settings
$imgTitle = new ImagickDraw();
//$imgTitle->setFont($strFont);
$imgTitle->setFont('DejaVu-Serif-Condensed-Bold');
$imgTitle->setFontWeight(100);
$imgTitle->setFontSize((int)$fontSize);
$imgTitle->setFillColor($textColor);
$imgTitle->setGravity(Imagick::GRAVITY_CENTER);
// Set the size of the text box and the bg color/transparency
$imgButtonText->setSize(153,58);
$imgButtonText->newImage(153, 58, "white");
$imgButtonText->paintTransparentImage("white", 0.0, 0.0);
// Add text to the textbox
$imgButtonText->annotateImage($imgTitle,0,0,0,$line1);
$imgButtonText->setImageFormat('png');
//output the new image
header('Content-type: image/png');
echo $imgButtonText;
//destroy the new image
$imgButtonText->destroy();
?>