PHP | Imagick queryFonts() Function

The Imagick::Imagick::queryFonts function is an inbuilt function in PHP which is used to returns the configured fonts of Imagick library.

Syntax:

array Imagick::queryFonts( $pattern = "*" )

Parameters: This function accepts single parameter $pattern which stores the value of the query pattern.

Return Value: This function returns an array containing all configured fonts.

Below programs illustrate the Imagick::queryFonts() function in PHP:

Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php 
  
$output = '';
$output .= "Fonts that match 'Times*' are:<br>";
  
// Imagick Object
$fontList = Imagick::queryFonts( "Times*" );
   
foreach ($fontList as $fontName) {
    $output .= $fontName;
}
  
// Output
echo $output; 
?>

chevron_right


Output:

Fonts that match 'Times*' are:
Times-Bold
Times-BoldItalic
Times-Italic
Times-Roman

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Create new Imagick object
$im = new Imagick(); 
  
// Display all fonts
var_dump( $im->queryFonts() ); 
?>

chevron_right


Output:

string(5) "array"
array(326) {
  [0] => string(5) "aakar"
  [1] => string(14) "Abyssinica-SIL"
  ...
  ...
  ...
  [325] => string(13) "Waree-Oblique"
}

Reference: http://php.net/manual/en/imagick.queryfonts.php



My Personal Notes arrow_drop_up

Image
Check out this Author's contributed articles.

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.