1

I'm trying to get Imagick to list all fonts in PHP. I found the following code in the PHP.net manual:

$fontList = \Imagick::queryFonts("*");

foreach ($fontList as $fontName) {
 $output .= '<li>'. $fontName."</li>";
}

return $output;

Unfortunately this doesn't work for me. I get the following PHP error which I don't understand:

Strict Standards: Non-static method Imagick::queryfonts() should not be called statically

Anyone have a suggestion? thanks!

user2874270
  • 1,312
  • 2
  • 18
  • 31
  • http://stackoverflow.com/questions/1392858/with-imagemagick-how-can-you-see-all-available-fonts – Progrock Aug 18 '16 at 23:22
  • @Progrock You have linked to an answer about the command line ImageMagick utilities. Which is not the same as Imagick, the PHP extension. – Danack Aug 19 '16 at 13:47
  • @Danack true. The Convert program is a member of the ImageMagick suite of tools. So is likely to be there. Not a pure Php solution, but may provide an alternative method. – Progrock Aug 19 '16 at 13:57
  • I notice that the example above was a quote from the manual. http://php.net/manual/en/imagick.queryfonts.php – Progrock Aug 19 '16 at 13:58
  • And the manual reflects the current version, not a 3 year old version of the code. – Danack Aug 19 '16 at 14:42

1 Answers1

2

You're apparently using a quite old version of Imagick. The queryFonts method was made to be callable by a static call back on Sep 25, 2013.

If you can't upgrade to a later version, you should be able to do:

$imagick = new Imagick();
$fonts = $imagick->queryfonts();
Danack
  • 24,939
  • 16
  • 90
  • 122