+

PHP ImagickDraw function setFontWeight ()

Syntax:
bool ImagickDraw::setFontWeight ($font_weight)
Parameters: this function takes one parameter, $font_weight, which is used to store the font weight value as an integer type.Return Value:This function returns True if success.The following programs illustrate the ImagickDraw::setFontWeight()function in PHP:Program 1:  
// Create an ImagickDraw object $draw = new ImagickDraw();  
// Set the fill color of the image $draw -> setFillColor ( `red` );  
// Set font weight $draw -> setFontWeight (200);  
// Set font size $draw -> setFontSize (40);  
// Install font family $draw -> setFontFamily ( `Ubuntu-Mono` );  
// Set text to add $draw -> annotation (30, 170, "GeeksForGeeks" );  
// Set the fill color of the image $draw -> setFillColor ( `green` );  
// Set font stretching $draw -> setFontStretch (3);  
// Set font size $draw -> setFontSize (30);  
// Install font family $draw -> setFontFamily ( `Open-Sans-Light-Italic` );  
// Set text to add $draw -> annotation (30, 250, "Font-Weight : 200 " );  
// Create a new imagick object $imagick = new Imagick();  
// Set image size $imagick -> newImage (350, 300, `white` );  
// Set image format $imagick -> setImageFormat ( "png" );  
// Draw image $imagick -> drawImage ( $draw ); header ( "Content-Type: image / png" );  
// Show image echo $imagick -> getImageBlob(); ?>
Output: Program 2:  
// Create ImagickDraw object $draw = new ImagickDraw();  
// Set the fill color of the image $draw -> setFillColor ( `Green` );  
// Set font size $draw -> setFontSize (30);  
// Set font weight $draw -> setFontWeight (400);  
// Install font family $draw -> setFontFamily ( `Ani` );  
// Set text to add $draw -> annotation (30, 40, "GeeksForGeeks" );  
// Create a new Imagick object $imagick = new Imagick();  
// Set image size $imagick -> newImage (250, 70, `white` );  
// Set image format $imagick -> setImageFormat ( "png" );  
// Draw image $imagick -> drawImage ( $draw ); header ( "Content-Type: image / png" );  
// Show image echo $imagick -> getImageBlob(); ?>
Output: Link: http://php.net/manual/en/imagickdraw.setfontweight.php
Get Solution for free from DataCamp guru