Is it possible to print a list of all fonts installed?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
charlie

Is it possible to print a list of all fonts installed?

Post by charlie »

Greetings,
I've been searching the forum for a couple of days, in an effort to find
some way to get ImageMagick to create a "font sheet". That is; create
a montage of all the fonts installed on my system. Sending:

Code: Select all

convert -list font
Indicates that IM knows where, and which fonts are installed on my system.
But doesn't print a sample of the fonts.
I looked at:
http://www.rubblewebs.co.uk./imagemagic ... _f_23.html
But, while it seems to work for RubbleWebs, it (as posted) can not work for anyone else. :(
The problem with the script is (at least) two fold;
line 3:

Code: Select all

preg_match(/^LIB_VERSION_NUMBER ([0-9,]+)$/m, shell_exec("convert -list configure "), $vnums);
can't possibly work because:

Code: Select all

/^LIB_VERSION_NUMBER ([0-9,]+)$/m
isn't quoted - ie;

Code: Select all

'/^LIB_VERSION_NUMBER ([0-9,]+)$/m'
Once that is corrected, the script breaks at line 40:

Code: Select all

$FirstPart = explode( , $NoPath[$i]);
This is basically a preg_split(). But I assume RubbleWebs is using explode()
because in many cases it is faster. The problem with all this is that both
methods require a delimiter. But I don't know which one RubbleWebs intended
to use - it should probably also be quoted - eg;

Code: Select all

$FirstPart = explode( "<some-delimiter>", $NoPath[$i]);
or

Code: Select all

$FirstPart = explode( '<some-delimiter>', $NoPath[$i]);
depending on your quoting needs.
Anyway, if anyone knows how to fix this, or has found a way to get IM to
create a font sheet. I'd really appreciate a pointer. :)

Thank you for all your time and consideration.

--Chuck
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Is it possible to print a list of all fonts installed?

Post by Bonzo »

Sorry about that Chuck

The code is OK on this page: http://www.rubblewebs.co.uk./imagemagic ... /fonts.php where it is in a file but the snippet section is in a database and I pressume magic quotes has had an effect!

A couple of the fonts may not be displayed or show up as ??????????????

Code: Select all

<?php 
// Select the version number from the configeration file
    preg_match('/^LIB_VERSION_NUMBER ([0-9,]+)$/m', shell_exec("convert -list configure "), $vnums);

// Seperate the numbers at the ,
    $number = explode( ",", $vnums[1] );

// Format the version from 6,3,4,1 format to 06030401
    $version = "";
    for($i=0;$i<4;$i++)
    {
    $version .= str_pad( $number[$i], 2, '0', STR_PAD_LEFT );
    } 

// The 'list' method used to get the fonts changed in IM v6.3.5-7
    $font_list = ( $version > "06030507" ) ? "font" : "type";

// Populate the array only - do not display it
    exec("convert -list $font_list", $IMarray, $code);

// Sort the array alphabeticly
    sort( $IMarray );

// Setup some default values
    $delete = array();
    $image_list = "";

// Function to remove items from array
    function array_delete( $array, $filterfor ){ 
        $thisarray = array (); 
        foreach( $array as $value ) 
        if( stristr( $value, $filterfor )===false && strlen( $value )>0) 
        $thisarray[] = $value; 
        return $thisarray; 
    } 

// Remove items containing Name from the arrary
    $NoName = array_delete( $IMarray, "Name" ); 

// Remove items containing Path: from the array
    $NoPath = array_delete( $NoName, "Path:" ); 

// Find the amount of items in the array
    $count = count( $NoPath );

// Reduce the count by one as the array starts at 0
    $count = $count-1;

// Start the loop to generate the images
    for ( $i=2; $i<=$count; $i++ ) {

// Get the font name from the array
        $FirstPart = explode(' ', $NoPath[$i]);
        $Font = $FirstPart['0'];
        $Image = $Font.".png";
        
// Create the images
        exec("convert -size 250x15 xc:lightblue -font $Font -pointsize 13 -draw \"gravity West fill black text 0,0 $Font \" $Image");

// Generate the list of images for use in the large image
        $image_list = $image_list." ".$Image;

// Generate the array of tempory images to delete
        $delete[] = $Image;
    }

// Create the large image
    exec("convert -background white -gravity Center $image_list -append fonts.png");

// Delete the tempory images
    foreach ( $delete as $value ) { 
        unlink( $value ); }
?> 
<img src="fonts.png">
charlie

Re: Is it possible to print a list of all fonts installed?

Post by charlie »

Hello Bonzo, and thank you very much for your reply!
I pressume magic quotes has had an effect!
Ahh, that might explain it. :)

I see you used a quoted space for a delimiter. When I was
trying to fix the copy I downloaded from the "snippets" area, I used a quoted space -
both single, as well as double quotes. But unfortunately, that just created an endless
loop. So I copied the version you just posted here (thank you). But I still have the
same problem. The script never ends, and (of course) nothing is displayed to the browser.
The loop is evidenced in my web servers error log as follows:

Code: Select all

convert: unable to open image `13': No such file or directory.
convert: unable to open image `13': No such file or directory.
convert: unable to open image `13': No such file or directory.
convert: unable to open image `13': No such file or directory.
convert: unable to open image `13': No such file or directory.
convert: unable to open image `13': No such file or directory.
convert: unable to open image `13': No such file or directory.
convert: unable to open image `13': No such file or directory.
convert: unable to open image `13': No such file or directory.
convert: unable to open image `13': No such file or directory.
convert: unable to open image `13': No such file or directory.
convert: unable to open image `13': No such file or directory.
convert: unable to open image `13': No such file or directory.
convert: unable to open image `13': No such file or directory.
It will continue repeating this message (hours, if I let it) until I
shut down the server. :(

Any thoughts as to why this is happening?

Thank you again for your thoughtful reply.

--Chuck

P.S. Here's a chunk of the output from convert -list font:

Code: Select all

Font: AvantGarde-Book
    family: AvantGarde
    style: Normal
    stretch: Normal
    weight: 400
  Font: AvantGarde-BookOblique
    family: AvantGarde
    style: Oblique
    stretch: Normal
    weight: 400
  Font: AvantGarde-Demi
    family: AvantGarde
    style: Normal
    stretch: Normal
    weight: 600
  Font: AvantGarde-DemiOblique
    family: AvantGarde
    style: Oblique
    stretch: Normal
    weight: 600
  Font: Bookman-Demi
    family: Bookman
    style: Normal
    stretch: Normal
    weight: 600
  Font: Bookman-DemiItalic
    family: Bookman
    style: Italic
    stretch: Normal
    weight: 600
  Font: Bookman-Light
    family: Bookman
    style: Normal
    stretch: Normal
    weight: 300
  Font: Bookman-LightItalic
    family: Bookman
    style: Italic
    stretch: Normal
    weight: 300
...
Path: System Fonts
  Font: Bitstream-Vera-Sans-Bold
    family: Bitstream Vera Sans
    style: Normal
    stretch: Normal
    weight: 700
  Font: Bitstream-Vera-Sans-Bold-Oblique
    family: Bitstream Vera Sans
    style: Oblique
    stretch: Normal
    weight: 700
  Font: Bitstream-Vera-Sans-Mono-Bold
    family: Bitstream Vera Sans Mono
    style: Normal
    stretch: Normal
    weight: 700
  Font: Bitstream-Vera-Sans-Mono-Bold-Oblique
    family: Bitstream Vera Sans Mono
    style: Oblique
    stretch: Normal
    weight: 700
  Font: Bitstream-Vera-Sans-Mono-Oblique
    family: Bitstream Vera Sans Mono
    style: Oblique
    stretch: Normal
    weight: 400
  Font: Bitstream-Vera-Sans-Mono-Roman
    family: Bitstream Vera Sans Mono
    style: Normal
    stretch: Normal
    weight: 400
  Font: Bitstream-Vera-Sans-Oblique
    family: Bitstream Vera Sans
    style: Oblique
    stretch: Normal
    weight: 400
...
Thanks again!
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Is it possible to print a list of all fonts installed?

Post by Bonzo »

The only 13 I can see is on this line:

Code: Select all

// Create the images
        exec("convert -size 250x15 xc:lightblue -font $Font -pointsize 13 -draw \"gravity West fill black text 0,0 $Font \" $Image");
So I pressume the problem is with the $Font, try changing the line to this and it will echo the command every time. You can then check it contains what it should contain.

Code: Select all

// Create the images
$cmd = "-size 250x15 xc:lightblue -font $Font -pointsize 13 -draw \"gravity West fill black text 0,0 $Font \" ";
echo $cmd."<br>";
exec("convert $cmd $Image");
charlie

Re: Is it possible to print a list of all fonts installed?

Post by charlie »

Hello Bonzo, and thank you very much for your reply.

Are you sure the modification you posted:

Code: Select all

$cmd = "-size 250x15 xc:lightblue -font $Font -pointsize 13 -draw \"gravity West fill black text 0,0 $Font \" ";
echo $cmd."<br />";
exec("convert $cmd $Image");
shouldn't have been:

Code: Select all

$cmd = "convert -size 250x15 xc:lightblue -font $Font -pointsize 13 -draw \"gravity West fill black text 0,0 $Font \" ";
echo $cmd."<br />";
exec("convert $cmd $Image");
Note the addition of convert -size 250x15

In any case, running it exactly as you posted it, returned exactly
the same error as before.
However, after making the modification as I thought you had intended it to
be, returns a slightly different error:

Code: Select all

convert: unable to open image `convert': No such file or directory.
convert: unable to open image `13': No such file or directory.
convert: unable to open image `convert': No such file or directory.
convert: unable to open image `13': No such file or directory.
convert: unable to open image `convert': No such file or directory.
convert: unable to open image `13': No such file or directory.
convert: unable to open image `convert': No such file or directory.
convert: unable to open image `13': No such file or directory.
convert: unable to open image `convert': No such file or directory.
convert: unable to open image `13': No such file or directory.
convert: unable to open image `convert': No such file or directory.
convert: unable to open image `13': No such file or directory.
The errors show up in the web log not the PHP error log.

Hope this helps.

Thank you again for all your time and consideration.

--Chuck

P.S. I just looked at it closer (your code), my mistake, you were correct.
I think I've been up a bit too long w/o sleep. :?
But I still can't seem to find where the issue might be. As near as I can tell,
it must be either earlier, or later (probably earlier), or I would have seen the
command ($cmd) echoed in the log/in the browser.

:(

Update:
As an experiment, I made 2 changes

Code: Select all

exec("convert $cmd $Image");
became

Code: Select all

system("convert $cmd $Image");
and

Code: Select all

 -pointsize 13 -draw
became - I'll bet you know what I've done here already. ;)

Code: Select all

 -pointsize 24 -draw
and guess what!
Yep, you're right. The error changed to:

Code: Select all

convert: unable to open image `24': No such file or directory.
repeatedly, as before. But at least we've got something to go on.
Is it possibly the order of the options?
Maybe (mis)quoting?
I'll continue to experiment.
If you think of something - please post it.

Thank you again for all your time and consideration.

--Chuck out...
charlie

Re: Is it possible to print a list of all fonts installed?

Post by charlie »

Hello again Bonzo.

Well, I did some more experimenting. It's clear now $Font is
empty. After trying several different changes, I finally ended up with this:

Code: Select all

<?php
// Select the version number from the configeration file
    preg_match('/^LIB_VERSION_NUMBER ([0-9,]+)$/m', shell_exec("convert -list configure "), $vnums);

// Seperate the numbers at the ,
    $number = explode( ",", $vnums[1] );

// Format the version from 6,3,4,1 format to 06030401
    $version = "";
    for($i=0;$i<4;$i++)
    {
    $version .= str_pad( $number[$i], 2, '0', STR_PAD_LEFT );
    }

// The 'list' method used to get the fonts changed in IM v6.3.5-7
    $font_list = ( $version > "06030507" ) ? "font" : "type";

// Populate the array only - do not display it
    exec("convert -list $font_list", $IMarray, $code);

// Sort the array alphabeticly
    sort( $IMarray );

// Setup some default values
    $delete = array();
    $image_list = "";

// Function to remove items from array
    function array_delete( $array, $filterfor ){
        $thisarray = array ();
        foreach( $array as $value )
        if( stristr( $value, $filterfor )===false && strlen( $value )>0)
        $thisarray[] = $value;
        return $thisarray;
    }

// Remove items containing Name from the arrary
    $NoName = array_delete( $IMarray, "Name");

// Remove items containing Path: from the array
    $NoPath = array_delete( $NoName, "Path:");

// Find the amount of items in the array
    $count = count( $NoPath );

// Reduce the count by one as the array starts at 0
    $count = $count-1;

// Start the loop to generate the images
    for ( $i=2; $i<=$count; $i++ ) {

// Get the font name from the array
        $FirstPart = explode(' ', $NoPath[$i]);
        $Font = $FirstPart['0'];
        $Image = $Font.'.png';
       
echo $Font."<br />";
    }

?>
This results in zero errors, and this is what's dumped to the browser:

Code: Select all

<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
I don't see any font names, do you?

I'll see if I can debug any more noise out of the script in hopes of finding
clue(s).

If you think of anything please post it. :)

--Chuck
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Is it possible to print a list of all fonts installed?

Post by Bonzo »

I am at work at the moment so have restrictive internet access.

I have just realised I am using Version: ImageMagick 6.3.5 on my server. I can try a later version when I get home and see what happens.
The 'list' method used to get the fonts changed in IM v6.3.5-7
What does this give you ?

Code: Select all

<?php 
// Select the version number from the configeration file
preg_match('/^LIB_VERSION_NUMBER ([0-9,]+)$/m', shell_exec("convert -list configure "), $vnums);

// Seperate the numbers at the ,
$number = explode( ",", $vnums[1] );

// Format the version from 6,3,4,1 format to 06030401
$version = "";

for($i=0;$i<4;$i++)
{
$version .= str_pad( $number[$i], 2, '0', STR_PAD_LEFT );
} 

// The 'list' method used to get the fonts changed in IM v6.3.5-7
$font_list = ( $version > "06030507" ) ? "font" : "type";

// Display the version of Imagemagick, the method to read the fonts and the list of fonts
echo "<h2>IM version: ".$version." </h2>\n
<h3>Method used: convert -list $font_list</h3>\n
<hr>\n<pre>";
system("convert -list $font_list");
echo "</pre>\n<hr>";
?> 
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Is it possible to print a list of all fonts installed?

Post by Bonzo »

I have just tried this at home and it will not work. As you say $Font does not contain anything.
I will look into it later - Version: ImageMagick 6.4.0
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Is it possible to print a list of all fonts installed?

Post by Bonzo »

Looks like I never tried this with a version over 6.3.5 as Imagemagick generates a different array !

A piece of code below that should work. I will tidy it up when I get time. Let me know how it goes and sorry for the problems.

Code: Select all

<?php 
system("convert -version");
// Select the version number from the configeration file
    preg_match('/^LIB_VERSION_NUMBER ([0-9,]+)$/m', shell_exec("convert -list configure "), $vnums);

// Seperate the numbers at the ,
    $number = explode( ",", $vnums[1] );

// Format the version from 6,3,4,1 format to 06030401
    $version = "";
    for($i=0;$i<4;$i++)
    {
    $version .= str_pad( $number[$i], 2, '0', STR_PAD_LEFT );
    } 	
	
// The 'list' method used to get the fonts changed in IM v6.3.5-7
    $font_list = ( $version > "06030507" ) ? "font" : "type";

// Populate the array only - do not display it
    exec("convert -list $font_list", $IMarray, $code);
	
// Sort the array alphabeticly
    sort( $IMarray );

// Setup some default values
    $delete = array();
    $image_list = "";

// Function to remove items from array
    function array_delete( $array, $filterfor ){ 
        $thisarray = array (); 
        foreach( $array as $value ) 
        if( stristr( $value, $filterfor )===false && strlen( $value )>0) 
        $thisarray[] = $value; 
        return $thisarray; 
    } 

// Remove items containing Name from the arrary
    $NoName = array_delete( $IMarray, "Name" ); 

// Remove items containing Path: from the array
    $NoPath = array_delete( $NoName, "Path:" ); 

// Remove items containing Path: from the array
    $NoFamily = array_delete( $NoPath, "family:" );
	
// Remove items containing Path: from the array
    $NoStretch = array_delete( $NoFamily, "stretch:" );
	
	// Remove items containing Path: from the array
    $NoWeight = array_delete( $NoStretch, "weight:" );
	
		// Remove items containing Path: from the array
    $NoStyle = array_delete( $NoWeight, "style:" );
	
// Find the amount of items in the array
    $count = count( $NoStyle );

// Reduce the count by one as the array starts at 0
    $count = $count-1;

// Start the loop to generate the images
    for ( $i=2; $i<=$count; $i++ ) {

// Get the font name from the array
        $FirstPart = explode(':', $NoStyle[$i]);
        $Font = str_replace( ' ', '', $FirstPart['1']);	
        $Image = $Font.".png";	
		
// Create the images
$cmd = "-size 250x15 xc:lightblue -font $Font -pointsize 13 -draw \"gravity West fill black text 0,0 $Font \" ";
// echo $cmd."<br>";
exec("convert $cmd $Image");

// Generate the list of images for use in the large image
        $image_list = $image_list." ".$Image;

// Generate the array of tempory images to delete
        $delete[] = $Image;
    }

// Create the large image
    exec("convert -background white -gravity Center $image_list -append fonts.png");

// Delete the tempory images
    foreach ( $delete as $value ) { 
        unlink( $value ); }
?> 
<img src="fonts.png">
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Is it possible to print a list of all fonts installed?

Post by Bonzo »

The two different outputs:
Version: ImageMagick 6.3.5 08/29/07 Q16 http://www.imagemagick.org Copyright: Copyright (C) 1999-2007 ImageMagick Studio LLC
Array
(
[0] =>
[1] =>
[2] =>
[3] =>
[4] => --------------------------------------------------------------------------------
[5] => --------------------------------------------------------------------------------
[6] => AvantGarde-Book AvantGarde Normal Normal 400
[7] => AvantGarde-BookOblique AvantGarde Oblique Normal 400
[8] => AvantGarde-Demi AvantGarde Normal Normal 600
[9] => AvantGarde-DemiOblique AvantGarde Oblique Normal 600
Version: ImageMagick 6.4.0 04/16/08 Q16 http://www.imagemagick.org Copyright: Copyright (C) 1999-2008 ImageMagick Studio LLC
Array
(
[0] =>
[1] =>
[2] => family: Arial
[3] => family: Arial
[4] => family: Arial
[5] => family: Arial
[6] => family: Arial
[7] => family: Arial Unicode MS
[8] => family: AvantGarde
[9] => family: AvantGarde

[161] => stretch: Condensed
[162] => stretch: Condensed
[163] => stretch: Condensed
[164] => stretch: Condensed

[320] => style: Italic
[321] => style: Italic
[322] => style: Italic
[323] => style: Italic
[324] => style: Italic

[479] => weight: 200
[480] => weight: 300
[481] => weight: 300
[482] => weight: 400
[483] => weight: 400

[638] => Font: Arial
[639] => Font: Arial-Black
[640] => Font: Arial-Bold
[641] => Font: Arial-Bold-Italic
[642] => Font: Arial-Italic
charlie

Re: Is it possible to print a list of all fonts installed?

Post by charlie »

Bonzo wrote:I am at work at the moment so have restrictive internet access.

I have just realised I am using Version: ImageMagick 6.3.5 on my server. I can try a later version when I get home and see what happens.
The 'list' method used to get the fonts changed in IM v6.3.5-7
Ahh, I have IM 6.3.5 on one of my other machines. But noticed you appear
to account for both (older and newer) versions:

Code: Select all

// The 'list' method used to get the fonts changed in IM v6.3.5-7
    $font_list = ( $version > "06030507" ) ? "font" : "type";
Bonzo wrote:What does this give you ?

Code: Select all

<?php 
// Select the version number from the configeration file
preg_match('/^LIB_VERSION_NUMBER ([0-9,]+)$/m', shell_exec("convert -list configure "), $vnums);

// ---8<---&<---BIG-SNIP-for brevity

<hr>\n<pre>";
system("convert -list $font_list");
echo "</pre>\n<hr>";
?> 
Ahh, I posted a portion of it's output earlier in this thread. :)

Here's the portion you're likely interested in:

Code: Select all

IM version: 06040304
Method used: convert -list font

Path: /usr/local/lib/ImageMagick-6.4.3/config/type-ghostscript.xml
  Font: AvantGarde-Book
    family: AvantGarde
    style: Normal
    stretch: Normal
    weight: 400
  Font: AvantGarde-BookOblique
    family: AvantGarde
    style: Oblique
    stretch: Normal
    weight: 400
  Font: AvantGarde-Demi
    family: AvantGarde

---8<---8<---8<---

Path: System Fonts
  Font: Bitstream-Vera-Sans-Bold
    family: Bitstream Vera Sans
    style: Normal
    stretch: Normal
    weight: 700
  Font: Bitstream-Vera-Sans-Bold-Oblique
    family: Bitstream Vera Sans
    style: Oblique
    stretch: Normal
    weight: 700
  Font: Bitstream-Vera-Sans-Mono-Bold
    family: Bitstream Vera Sans Mono
    style: Normal

---8<---8<---8<---

Font: Serto-Mardin-Regular
    family: Serto Mardin
    style: Normal
    stretch: Normal
    weight: 400
  Font: Serto-Urhoy-Bold
    family: Serto Urhoy
    style: Normal
    stretch: Normal
    weight: 700
  Font: Serto-Urhoy-Regular
    family: Serto Urhoy
    style: Normal
    stretch: Normal
    weight: 400
HTH

--Chuck
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Is it possible to print a list of all fonts installed?

Post by Bonzo »

Check out my other posts Chuck.

Off to bed now - I will check your results tomorrow.
charlie

Re: Is it possible to print a list of all fonts installed?

Post by charlie »

Bonzo wrote:Looks like I never tried this with a version over 6.3.5 as Imagemagick generates a different array !

A piece of code below that should work. I will tidy it up when I get time. Let me know how it goes and sorry for the problems.

Code: Select all

<?php 
system("convert -version");
// Select the version number from the configeration file
    preg_match('/^LIB_VERSION_NUMBER ([0-9,]+)$/m', shell_exec("convert -list configure "), $vnums);

// Seperate the numbers at the ,
    $number = explode( ",", $vnums[1] );

--8<---8<---8<---BIG-SNIP-for brevity---

// Delete the tempory images
    foreach ( $delete as $value ) { 
        unlink( $value ); }
?> 
<img src="fonts.png">
Woohoo! you're the man!

I went to bed (7am. been up all night working) scratching my head about this
section:

Code: Select all

// Remove items containing Name from the arrary
    $NoName = array_delete( $IMarray, "Name" );

// Remove items containing Path: from the array
    $NoPath = array_delete( $NoName, "Path:" );
Now I know why. ;)

That's the trick. Works like a champ! :lol:

Thank you Bonzo for all your time and consideration.
I really appreciate it. :) I give you a 2 thumbs up. :)

--Chuck

P.S. I got frustrated earlier and decided to see if I could coerce montage
into making me a font sheet out of:

Code: Select all

convert -list font
and here's what I used:

Code: Select all

#!/bin/sh -

montage -pointsize 32 \
-font AvantGarde-Book                       -label AvantGarde-Book                       label:aAlLoObBcCwWmM-01235789 \
-font AvantGarde-BookObliq                  -label AvantGarde-BookObliq                  label:aAlLoObBcCwWmM-01235789 \
-font AvantGarde-Demi                       -label AvantGarde-Demi                       label:aAlLoObBcCwWmM-01235789 \
-font AvantGarde-DemiObliq                  -label AvantGarde-DemiObliq                  label:aAlLoObBcCwWmM-01235789 \
-font Bookman-Demi                          -label Bookman-Demi                          label:aAlLoObBcCwWmM-01235789 \
-font Bookman-DemiItalic                    -label Bookman-DemiItalic                    label:aAlLoObBcCwWmM-01235789 \
-font Bookman-Light                         -label Bookman-Light                         label:aAlLoObBcCwWmM-01235789 \
-font Bookman-LightItalic                   -label Bookman-LightItalic                   label:aAlLoObBcCwWmM-01235789 \
-font Courier                               -label Courier                               label:aAlLoObBcCwWmM-01235789 \
-font Courier-Bold                          -label Courier-Bold                          label:aAlLoObBcCwWmM-01235789 \
-font Courier-BoldOblique                   -label Courier-BoldOblique                   label:aAlLoObBcCwWmM-01235789 \
-font Courier-Oblique                       -label Courier-Oblique                       label:aAlLoObBcCwWmM-01235789 \
-font fixed                                 -label fixed                                 label:aAlLoObBcCwWmM-01235789 \
-font Helvetica                             -label Helvetica                             label:aAlLoObBcCwWmM-01235789 \
-font Helvetica-Bold                        -label Helvetica-Bold                        label:aAlLoObBcCwWmM-01235789 \
-font Helvetica-BoldObliqu                  -label Helvetica-BoldObliqu                  label:aAlLoObBcCwWmM-01235789 \
-font Helvetica-Narrow                      -label Helvetica-Narrow                      label:aAlLoObBcCwWmM-01235789 \
-font Helvetica-Narrow-Bol                  -label Helvetica-Narrow-Bol                  label:aAlLoObBcCwWmM-01235789 \
-font Helvetica-Narrow-Bol                  -label Helvetica-Narrow-Bol                  label:aAlLoObBcCwWmM-01235789 \
-font Helvetica-Narrow-Obl                  -label Helvetica-Narrow-Obl                  label:aAlLoObBcCwWmM-01235789 \
-font Helvetica-Oblique                     -label Helvetica-Oblique                     label:aAlLoObBcCwWmM-01235789 \
-font NewCenturySchlbk-Bol                  -label NewCenturySchlbk-Bol                  label:aAlLoObBcCwWmM-01235789 \
-font NewCenturySchlbk-Bol                  -label NewCenturySchlbk-Bol                  label:aAlLoObBcCwWmM-01235789 \
-font NewCenturySchlbk-Ita                  -label NewCenturySchlbk-Ita                  label:aAlLoObBcCwWmM-01235789 \
-font NewCenturySchlbk-Rom                  -label NewCenturySchlbk-Rom                  label:aAlLoObBcCwWmM-01235789 \
-font Palatino-Bold                         -label Palatino-Bold                         label:aAlLoObBcCwWmM-01235789 \
-font Palatino-BoldItalic                   -label Palatino-BoldItalic                   label:aAlLoObBcCwWmM-01235789 \
-font Palatino-Italic                       -label Palatino-Italic                       label:aAlLoObBcCwWmM-01235789 \
-font Palatino-Roman                        -label Palatino-Roman                        label:aAlLoObBcCwWmM-01235789 \
-font Symbol                                -label Symbol                                label:aAlLoObBcCwWmM-01235789 \
-font Times-Bold                            -label Times-Bold                            label:aAlLoObBcCwWmM-01235789 \
-font Times-BoldItalic                      -label Times-BoldItalic                      label:aAlLoObBcCwWmM-01235789 \
-font Times-Italic                          -label Times-Italic                          label:aAlLoObBcCwWmM-01235789 \
-font Times-Roman                           -label Times-Roman                           label:aAlLoObBcCwWmM-01235789 \
-font Bitstream-Vera-Sans-Bold              -label Bitstream-Vera-Sans-Bold              label:aAlLoObBcCwWmM-01235789 \
-font Bitstream-Vera-Sans-Bold-Oblique      -label Bitstream-Vera-Sans-Bold-Oblique      label:aAlLoObBcCwWmM-01235789 \
-font Bitstream-Vera-Sans-Mono-Bold         -label Bitstream-Vera-Sans-Mono-Bold         label:aAlLoObBcCwWmM-01235789 \
-font Bitstream-Vera-Sans-Mono-Bold-Oblique -label Bitstream-Vera-Sans-Mono-Bold-Oblique label:aAlLoObBcCwWmM-01235789 \
-font Bitstream-Vera-Sans-Mono-Oblique      -label Bitstream-Vera-Sans-Mono-Oblique      label:aAlLoObBcCwWmM-01235789 \
-font Bitstream-Vera-Sans-Mono-Roman        -label Bitstream-Vera-Sans-Mono-Roman        label:aAlLoObBcCwWmM-01235789 \
-font Bitstream-Vera-Sans-Oblique           -label Bitstream-Vera-Sans-Oblique           label:aAlLoObBcCwWmM-01235789 \
-font Bitstream-Vera-Sans-Roman             -label Bitstream-Vera-Sans-Roman             label:aAlLoObBcCwWmM-01235789 \
-font Bitstream-Vera-Serif-Bold             -label Bitstream-Vera-Serif-Bold             label:aAlLoObBcCwWmM-01235789 \
-font Bitstream-Vera-Serif-Roman            -label Bitstream-Vera-Serif-Roman            label:aAlLoObBcCwWmM-01235789 \
-font East-Syriac-Adiabene-Regular          -label East-Syriac-Adiabene-Regular          label:aAlLoObBcCwWmM-01235789 \
-font East-Syriac-Ctesiphon-Regular         -label East-Syriac-Ctesiphon-Regular         label:aAlLoObBcCwWmM-01235789 \
-font Estrangelo-Antioch-Regular            -label Estrangelo-Antioch-Regular            label:aAlLoObBcCwWmM-01235789 \
-font Estrangelo-Edessa-Regular             -label Estrangelo-Edessa-Regular             label:aAlLoObBcCwWmM-01235789 \
-font Estrangelo-Midyat-Regular             -label Estrangelo-Midyat-Regular             label:aAlLoObBcCwWmM-01235789 \
-font Estrangelo-Nisibin-Outline-Regular    -label Estrangelo-Nisibin-Outline-Regular    label:aAlLoObBcCwWmM-01235789 \
-font Estrangelo-Nisibin-Regular            -label Estrangelo-Nisibin-Regular            label:aAlLoObBcCwWmM-01235789 \
-font Estrangelo-Quenneshrin-Regular        -label Estrangelo-Quenneshrin-Regular        label:aAlLoObBcCwWmM-01235789 \
-font Estrangelo-Talada-Regular             -label Estrangelo-Talada-Regular             label:aAlLoObBcCwWmM-01235789 \
-font Estrangelo-TurAbdin-Regular           -label Estrangelo-TurAbdin-Regular           label:aAlLoObBcCwWmM-01235789 \
-font Goha-Tibeb-Zemen-Regular              -label Goha-Tibeb-Zemen-Regular              label:aAlLoObBcCwWmM-01235789 \
-font Luxi-Mono-Bold                        -label Luxi-Mono-Bold                        label:aAlLoObBcCwWmM-01235789 \
-font Luxi-Mono-Bold-Oblique                -label Luxi-Mono-Bold-Oblique                label:aAlLoObBcCwWmM-01235789 \
-font Luxi-Mono-Oblique                     -label Luxi-Mono-Oblique                     label:aAlLoObBcCwWmM-01235789 \
-font Luxi-Mono-Regular                     -label Luxi-Mono-Regular                     label:aAlLoObBcCwWmM-01235789 \
-font Luxi-Sans-Bold                        -label Luxi-Sans-Bold                        label:aAlLoObBcCwWmM-01235789 \
-font Luxi-Sans-Bold-Oblique                -label Luxi-Sans-Bold-Oblique                label:aAlLoObBcCwWmM-01235789 \
-font Luxi-Sans-Oblique                     -label Luxi-Sans-Oblique                     label:aAlLoObBcCwWmM-01235789 \
-font Luxi-Sans-Regular                     -label Luxi-Sans-Regular                     label:aAlLoObBcCwWmM-01235789 \
-font Luxi-Serif-Bold                       -label Luxi-Serif-Bold                       label:aAlLoObBcCwWmM-01235789 \
-font Luxi-Serif-Bold-Oblique               -label Luxi-Serif-Bold-Oblique               label:aAlLoObBcCwWmM-01235789 \
-font Luxi-Serif-Oblique                    -label Luxi-Serif-Oblique                    label:aAlLoObBcCwWmM-01235789 \
-font Luxi-Serif-Regular                    -label Luxi-Serif-Regular                    label:aAlLoObBcCwWmM-01235789 \
-font Serto-Batnan-Bold                     -label Serto-Batnan-Bold                     label:aAlLoObBcCwWmM-01235789 \
-font Serto-Batnan-Regular                  -label Serto-Batnan-Regular                  label:aAlLoObBcCwWmM-01235789 \
-font Serto-Jerusalem-Bold                  -label Serto-Jerusalem-Bold                  label:aAlLoObBcCwWmM-01235789 \
-font Serto-Jerusalem-Italic                -label Serto-Jerusalem-Italic                label:aAlLoObBcCwWmM-01235789 \
-font Serto-Jerusalem-Outline-Regular       -label Serto-Jerusalem-Outline-Regular       label:aAlLoObBcCwWmM-01235789 \
-font Serto-Jerusalem-Regular               -label Serto-Jerusalem-Regular               label:aAlLoObBcCwWmM-01235789 \
-font Serto-Kharput-Regular                 -label Serto-Kharput-Regular                 label:aAlLoObBcCwWmM-01235789 \
-font Serto-Malankara-Regular               -label Serto-Malankara-Regular               label:aAlLoObBcCwWmM-01235789 \
-font Serto-Mardin-Bold                     -label Serto-Mardin-Bold                     label:aAlLoObBcCwWmM-01235789 \
-font Serto-Mardin-Regular                  -label Serto-Mardin-Regular                  label:aAlLoObBcCwWmM-01235789 \
-font Serto-Urhoy-Bold                      -label Serto-Urhoy-Bold                      label:aAlLoObBcCwWmM-01235789 \
-font Serto-Urhoy-Regular                   -label Serto-Urhoy-Regular                   label:aAlLoObBcCwWmM-01235789 \
\
-frame 0  -geometry +1+1 -font Bitstream-Vera-Sans-Mono-Roman -pointsize 12 \
-background snow1 -bordercolor ivory1 -mattecolor ivory1 \
font_sheet.png

exit
Works pretty good, but I wish I could figure out how to get the font listing to
be only one column wide. As it is, it's 4 columns wide.

Best wishes.

--Chuck
:
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Is it possible to print a list of all fonts installed?

Post by fmw42 »

Have you tried Anthony's show_fonts, graphics_utf and text2img_fixed scripts at http://www.imagemagick.org/Usage/scripts/

see a simple example at viewtopic.php?f=1&t=12416&hilit=show_fonts
charlie

Re: Is it possible to print a list of all fonts installed?

Post by charlie »

Hello fmw42, and thank you for your reply.
Have you tried Anthony's show_fonts, graphics_utf and text2img_fixed scripts at http://www.imagemagick.org/Usage/scripts/
Yes, I have. But am having trouble getting several of them to work as described. :(
see a simple example at viewtopic.php?f=1&t=12416&hilit=show_fonts
I had a look at this. The show_fonts script is one of the ones that isn't working.
For example, the example in the thread uses:

Code: Select all

show_fonts -2 -o arial2.png Arial
Using a slight variation:

Code: Select all

./show_fonts -2 -o ./Archway-Regular.png Archway-Regular
returns the following error:

Code: Select all

expr: illegal option -- 2
usage: expr [-e] expression
Looking at the script indicates that -2 is a legal option - and the one I am
interested in, eg; the full ASCII table.
Perhaps this is for the Windows version of sh - tho I don't think Windows is smart
enough to actually provide a real (C)shell. ;)

Anyway, it turned out to be a bit of a disappointment. But I greatly your
taking the time to help. Thanks. :)

--Chuck
Post Reply