Syntax:array Imagick::queryFontMetrics ($properties, $text, $multiline)
Parameters: This function takes three parameters as above and described below:
- $properties:This parameter contains the properties of the font.
- $text:this parameter contains text content.
- $multiline:contains the multiline parameter. If left blank, it is automatically detected.
Return Value: Returns a multidimensional array representing font metrics.The following program illustrates the Imagick function::queryFontMetrics() in PHP:
Program: This example returns the font properties of the text content "GeeksForGeeks".
/ * Create a new Imagick object * /
$im
=
new
Imagick();
/ * Create ImagickDraw object * /
$draw
=
new
ImagickDraw();
/ * Install font * /
$draw
-> setFillColor (
new
ImagickPixel (
’gray’
));
// Top left will be the starting point
$draw
-> setGravity (Imagick::GRAVITY_NORTHWEST);
/ * Dump font metrics, autodetect multiline * /
var_dump (
$im
-> queryFontMetrics ( $draw
,
"GeeksForGeeks"
));
?>
Output:array (10) {["characterWidth"] = > float (12) ["characterHeight"] = > float (12) ["ascender"] = > float (9) ["descender"] = > float (-3) ["textWidth"] = > float (88) ["textHeight"] = > float (15) ["maxHorizontalAdvance"] = > float (13) ["boundingBox"] = > array (4) {["x1"] = > float (0.40625) ["y1"] = > float (-0.046875) ["x2"] = > float (5.515625) ["y2"] = > float (7)} ["originX"] = > float (88) ["originY"] = > float (0)}
Link: https://www .php.net / manual / en / imagick.queryfontmetrics.php