PHP | ImagickDraw setFontWeight() Function
The ImagickDraw::setFontWeight() function is an inbuilt function in PHP which is used to set the font-weight.
Syntax:
bool ImagickDraw::setFontWeight( $font_weight )
Parameters: This function accepts a single parameter $font_weight which is used to hold the value of font weight as integer type.
Return Value: This function returns True on success.
Below programs illustrates the ImagickDraw::setFontWeight() function in PHP:
Program 1:
<?php // Create an ImagickDraw object $draw = new ImagickDraw(); // Set the image filled color $draw->setFillColor('red'); // Set the Font Weight $draw->setFontWeight(200); // Set the font size $draw->setFontSize(40); // Set the font family $draw->setFontFamily('Ubuntu-Mono'); // Set the text to be added $draw->annotation(30, 170, "GeeksForGeeks"); // Set the image filled color $draw->setFillColor('green'); // Set the Font Stretch $draw->setFontStretch(3); // Set the font size $draw->setFontSize(30); // Set the font family $draw->setFontFamily('Open-Sans-Light-Italic'); // Set the text to be added $draw->annotation(30, 250, "Font-Weight : 200"); // Create new imagick object $imagick = new Imagick(); // Set the image dimension $imagick->newImage(350, 300, 'white'); // Set the image format $imagick->setImageFormat("png"); // Draw the image $imagick->drawImage($draw); header("Content-Type: image/png"); // Display the image echo $imagick->getImageBlob(); ?> |
Output:
Program 2:
<?php // Create an ImagickDraw object $draw = new ImagickDraw(); // Set the image filled color $draw->setFillColor('Green'); // Set the font size $draw->setFontSize(30); // Set the Font Weight $draw->setFontWeight(400); // Set the font family $draw->setFontFamily('Ani'); // Set the text to be added $draw->annotation(30, 40, "GeeksForGeeks"); // Create new Imagick object $imagick = new Imagick(); // Set the image dimension $imagick->newImage(250, 70, 'white'); // Set the image format $imagick->setImageFormat("png"); // Draw the image $imagick->drawImage($draw); header("Content-Type: image/png"); // Display the image echo $imagick->getImageBlob(); ?> |
Output:

Reference: http://php.net/manual/en/imagickdraw.setfontweight.php
Recommended Posts:
- PHP | GmagickDraw setfontweight() Function
- PHP | ImagickDraw arc() Function
- PHP | ImagickDraw setStrokeOpacity() Function
- PHP | ImagickDraw polygon() Function
- PHP | ImagickDraw skewX() Function
- PHP | ImagickDraw roundRectangle() Function
- PHP | ImagickDraw setStrokeWidth() Function
- PHP | ImagickDraw line() Function
- PHP | ImagickDraw setStrokeMiterLimit() Function
- PHP | ImagickDraw setFillOpacity() Function
- PHP | ImagickDraw point() Function
- PHP | ImagickDraw setFontSize() Function
- PHP | ImagickDraw setFontFamily() Function
- PHP | ImagickDraw setGravity() Function
- PHP | ImagickDraw setFontStyle() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : nidhi_biet



