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?".
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 glad we got it sorted Chuck; I will update my webpage and look at tidying up the array section of the code as its a bit messy now.

There is a saying I should remember "Don't assume check".

I tend to do most of my examples with convert as there are a lot more options for it. I also think using php and the command line options is the best method over the APIs as you can import variables and build it into the code a lot easyer.
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 »

charlie wrote: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

You probably need cygwin on Windows as the scripts are for Unix bash. But perhaps Anthony can help you with it.
charlie

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

Post by charlie »

Bonzo wrote:I am glad we got it sorted Chuck; I will update my webpage and look at tidying up the array section of the code as its a bit messy now.
Me too! Thank you again very much for all your time. :)
Bonzo wrote:There is a saying I should remember "Don't assume check".
I am familiar with a similar one -
"Never assume. It will always make as ass out of you and me" ;)
Bonzo wrote:I tend to do most of my examples with convert as there are a lot more options for it. I also think using php and the command line options is the best method over the APIs as you can import variables and build it into the code a lot easyer.
I'm inclined to agree. But am still getting familiar with IM. So I'm not yet well enough
acquainted with it to fully realize/leverage all it's power - I just know it exists. :)

Take care.

--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 »

When I first started with Imagemagick and php I just could not get it to work and visited the problem agian and agian. That is why I started the section on my website as there were no other examples on the net I could find.
charlie

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

Post by charlie »

fmw42 wrote:
charlie wrote: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

You probably need cygwin on Windows as the scripts are for Unix bash. But perhaps Anthony can help you with it.
Hello fmw42, and thank you for your thoughtful reply.

I'm afraid I wasn't very clear - sorry.
I'll try again. :)

The problem I'm having with the show_fonts script is actually
on a *NIX based system (BSD, to be exact). ANyway, having read my response, I
can understand the confusion - sorry. It was "tounge-in-cheek", but I think I bit my tounge. ;).

Anyway, I ended up using convert && montage thusly:

Code: Select all

convert -list type
to get the font list

Code: Select all

#!/bin/sh -

convert -font AvantGarde-Book                        -pointsize 24 label:@atable AvantGarde-Book.png
convert -font AvantGarde-BookOblique                 -pointsize 24 label:@atable AvantGarde-BookOblique.png
convert -font AvantGarde-Demi                        -pointsize 24 label:@atable AvantGarde-Demi.png
convert -font AvantGarde-DemiOblique                 -pointsize 24 label:@atable AvantGarde-DemiOblique.png
convert -font Bookman-Demi                           -pointsize 24 label:@atable Bookman-Demi.png
convert -font Bookman-DemiItalic                     -pointsize 24 label:@atable Bookman-DemiItalic.png
convert -font Bookman-Light                          -pointsize 24 label:@atable Bookman-Light.png
convert -font Bookman-LightItalic                    -pointsize 24 label:@atable Bookman-LightItalic.png

---8<---8<---8<---150 fonts later

convert -font Utopia-Bold                            -pointsize 24 label:@atable Utopia-Bold.png
convert -font Utopia-Bold-Italic                     -pointsize 24 label:@atable Utopia-Bold-Italic.png
convert -font Utopia-Italic                          -pointsize 24 label:@atable Utopia-Italic.png
convert -font Utopia-Regular                         -pointsize 24 label:@atable Utopia-Regular.png
convert -font Vanilla-Whale-Regular                  -pointsize 24 label:@atable Vanilla-Whale-Regular.png
convert -font Verdana-Bold                           -pointsize 24 label:@atable Verdana-Bold.png
convert -font Verdana-Bold-Italic                    -pointsize 24 label:@atable Verdana-Bold-Italic.png
convert -font Verdana-Italic                         -pointsize 24 label:@atable Verdana-Italic.png
convert -font Verdana-Regular                        -pointsize 24 label:@atable Verdana-Regular.png
convert -font Waltograph-Regular                     -pointsize 24 label:@atable Waltograph-Regular.png
convert -font Webdings-Regular                       -pointsize 24 label:@atable Webdings-Regular.png

exit
@atable

Code: Select all

1234567890  \`  \" .,:;!?
abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ
@#\$\&*+-=~^_ ()[]{}<>\\/|
This, as you would know, left me with individual samples of all of my installed fonts.
I also needed to remove the backtick, because IM (and or, my shell) kept tripping over it.

I then used a deivitive of one of your scripts (photo_store)
to generate a sheet containing all of the individual font samples created earlier.

The changes I made to the (your) script were
  • Removed the -resize option - because the images were already the size I needed them to be.
  • Brought it up to date with todays standards - XHTML 1.0-strict compliance
  • Added a small amount of CSS in the <head>; section.
If you're interested, I'd be happy to post it for you (adding back in the -resize, of course).

Anyway. It's not very efficient. But I'm still just getting familiar with IM,
and don't yet know it well enough to do it in the most efficient fashion.
I do have some good friends - egrep, sed, sort, uniq & awk. Whom I am
very well acquainted with. They are masters at what they do.
But aren't very "self-motivated". So I have to tell them how I want them to
do the jobs they do so well. :)
They are so good, in fact. That they (with a little guidance) have been able to
accumulate over 4 million naughty addresses (SPAM sources). Simply by examining
some of the records in my maillogs. It's a RBL system I've been developing over
the past year. It rivals every other system available. And to-date, I have
not added one single "false-positive". I'll be releasing it in Q1 of next year.

To the point...
Now that I have experimented with, and found out how to achieve the desired
results from IM. I'll cobble up a couple of scripts (shell - sh) that will produce
the results I achieved above. Actually, I can do the above in one script.
I'll post it here, if anyone is interested. Or you'd like to add it to your "scripts"
section.

Back to your show_fonts -
I think what might be the trouble I (and the person in that thread also was having) is
related to either
1. The quote method you used (double), or
2. The "backtick(s)" intended for printing.
3. Or both.
In my experience, "quoting" was a frequent issue for me in my earlier scripts.
This is likely because my default shell is a Cshell (csh). So I
simply fire off my #!/bin/sh- scripts as

Code: Select all

# ./scriptname
I just now remembered this issue. So I'll re-attempt to use your script thusly:

Code: Select all

# sh ./scriptname
and report back if that solved (eliminated) the complaints I received when I
tried to use it before.

Well. I see this post is beginning to become a Novel. So I'll end it here by
thanking you again for all your hard work, the time you've shared so generously,
and your thoughtful response.

--Chuck out...
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 »

Unless a typo, photo_store is not one of my scripts. Perhaps one of Anthony's?

Fred
charlie

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

Post by charlie »

fmw42 wrote:Unless a typo, photo_store is not one of my scripts. Perhaps one of Anthony's?

Fred
D'oh! Right you are.

Sorry for that. :? What's worse, I did know that - I was examining the script
as I wrote the post. Sheesh.

Best wishes.

--Chuck
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

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

Post by anthony »

charlie wrote: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
From that error I can only conclude that the 'expr' program works slightly differently under Windows.

Essentually it should call graphics_utf and pipe its output into a convert script for display. All very simular to the examples on displaying UNICODE charcaters from IM Usage Examples, Text Handling. You can always go back to those basics.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
rossdv8
Posts: 47
Joined: 2014-03-12T21:54:20-07:00
Authentication code: 6789

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

Post by rossdv8 »

I did a lot of searching on this looking for a way to tell IM to print a sample of each font on my Linux system. I could not find an answer anywhere. It is slimple to make IM list all available fonts, and it is possible to use -convert to print each font individually. It does not seem simple or even possible to simply ask imagemagick to print a sample of each font without specifying each font name in a script that would in my case, end up about 550 lines long.

So here is how I get a printed list of samples of all the fonts available on my system:
I should add that I use Linux Mint 17 KDE, but any version of Linux should be similar.

First I open system settings:

Next, I open Font Management:

Then I select ALL the fonts by clicking the first one in the list, then scrolling to the bottom of the list and clicking the last one while holding down SHIFT.

Now I can right click the highlighted (blue) area and choose 'Print". A dialog will pop up asking what size I want the samples printed at. I choose 48pt because it is a convenient size for me to read and see at a glance how a font will look on a design:

I can now choose my printer from the list. Usually I will choose 'Print to file' and print a PDF file that I can produce later, or send to my tablet to study later.

It is a convenient way to look through hundreds of fonts. By printing to a PDF file I can browse at my leisure and send only pages with particularly useful or interesting fonts to my printer, saving toner/ink and paper.
If you send direct to your printer, and you have a lot of fonts, make sure you have plenty of paper loaded.

The blog entry here for Saturday 12th July 2014 has step by step images:
http://rossdevitt.blogspot.com.au/
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 »

see http://www.imagemagick.org/Usage/scripts/show_fonts. It is one of Anthony's scripts.
rossdv8
Posts: 47
Joined: 2014-03-12T21:54:20-07:00
Authentication code: 6789

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

Post by rossdv8 »

Thanks Fred,

I missed that script somehow when I was searching and for some reason I could not get my own efforts to loop.

I will try Anthony's script and probably use both methods. It took me a while to realise I could print the results of the Linux Font Manager (because there is no menu). I only found it when I accidentally right clicked the window.

I am getting used to using IM and have used many of Anthony's scripts as a basis to create some of my own for doing jobs I would normally do in GIMP.

Creating interesting font effects from the command line is just another example of how useful IM can be, but it helps to be able to see the font you plan to work with.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post by snibgo »

A very simple Windows BAT script to list fonts:

Code: Select all

rem Makes an image showing all available fonts.

set OUTFILE=listFonts.png

set PNT_SIZE=20

set SAMPLE_TEXT="  Hello world\n  ABCabc123"

%IM%convert xc: %OUTFILE%

for /F "usebackq tokens=2" %%F ^
in (`%IM%convert -list font ^| findstr Font:`) ^
do (
  %IM%convert ^
    %OUTFILE% ^
    ^( ^
      -pointsize %PNT_SIZE% ^
      label:%%F ^
      -font %%F ^
      label:%SAMPLE_TEXT% ^
      +append ^
    ^) ^
    -append ^
    %OUTFILE%
)
"-list font" is piped to findstr, which pulls out just the lines containing "Font:". This is looped through, extracting the 2nd token from each line, which is the font name. "convert" makes an image with the font name in default font, and a sample string in the named font.

This appends to an ever-increasing image, so it slows down towards the end. Very crude, but easily adaptable to any language.
snibgo's IM pages: im.snibgo.com
rossdv8
Posts: 47
Joined: 2014-03-12T21:54:20-07:00
Authentication code: 6789

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

Post by rossdv8 »

Thanks snibgo,

I'll see if I can use some of that to create a shell script. It was pulling the second token to create a loop I was having trouble with.

What I want to achieve in the end is the same thing as I can do using the Linux Font manager. A file I can view on screen or print at my option.

I am pretty sure IM can output a PDF, so it would be a simple solution to cover both options.
I have searched and seen a lot of suggestions for how this show fonts thing might work, but I still haven't found an example of one that works or managed to create one myself.

I've tried Anthony's script, but it seems to require entering each font name in the system. I have over 500, most of which I don't use, which is why I am trying to create something that will search for all the font names and print the display output to a PDF.

I'll have a play with your idea.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post by snibgo »

For your purpose, you could chop my script into two. First half: write a list of IM fonts to a text file. After manually editing the file, the second half would make an image.
snibgo's IM pages: im.snibgo.com
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

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

Post by anthony »

For details on the script see...
IM Examples, Montage, Re-Using Settings for Image Read/Creation
http://www.imagemagick.org/Usage/montage/#reuse
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply