Search code examples
phpnode.jsimagemagicklamp

Getting a list of all client side fonts using ImageMagik?


I'm looked around and saw a lot of questions about getting installed fonts on a system, but most of them are asking in the opposite way that I am. People are saying 'Is font x installed on the system', instead I am looking for 'What fonts are installed on the system'. In a different post I noticed that someone had gotten the information from ImageMagik using the following code:

<?php
$imagick = new Imagick();
$fonts = $imagick->queryFonts();
foreach($fonts as $font)
{
    echo $font;
}
?>

This displays the following

<section class='columns six'><h1 id='Abyssinica-SIL-Regular'>Abyssinica-SIL-Regular</h1></section>
<section class='columns six'><h1 id='AvantGarde-Book'>AvantGarde-Book</h1></section>
<section class='columns six'><h1 id='AvantGarde-BookOblique'>AvantGarde-BookOblique</h1></section>
<section class='columns six'><h1 id='AvantGarde-Demi'>AvantGarde-Demi</h1></section>
<section class='columns six'><h1 id='AvantGarde-DemiOblique'>AvantGarde-DemiOblique</h1></section>
<section class='columns six'><h1 id='Bitstream-Charter-Bold'>Bitstream-Charter-Bold</h1></section>

Though it doesn't seem it displays the CLIENT side fonts, instead it displays the fonts on the SERVER side. Is this true?

If this is true, is there a way to display ALL client side fonts using ImageMagik or possibly a different library?


Solution

  • The code which runs serverside is completely different from the code running on the client. It is possible to get a list of the fonts available on the client but not using HTML/CSS/Javascript although you can test for the presence of specific fonts using HTML/CSS/javascript - see the section on fonts here.

    It would help to know what you were trying to achieve - CSS already has a method for declaring alternate fonts.