使用 ImageMagick,如何查看所有可用的字体?

ImageMagick 可以用给定的字体将文本绘制到图片中,如何查看系统中所有可用的字体?

40529 次浏览

depending on your imagemagick version:

convert -list type       # for IM older than v6.3.5-7
convert -list font       # for newer versions

also the output format changed...

-- update For OsX (Answer from Charles Merriam) if the command above does not produce any results:

For a full tutorial with description see http://gothick.org.uk/2008/03/14/using-os-x-fonts-in-imagemagick/ for the rest &tldr:

# use fondu to convert fonts and update locatedb
sudo port install fondu
cd /usr/local/share/fonts/
fondu /Library/Fonts/*.dfont
/etc/periodic/weekly/310.locate


# generate imagemagick type.xml
cd ~
mkdir ~/.magick
wget http://www.imagemagick.org/Usage/scripts/imagick_type_gen
perl imagick_type_gen > ~/.magick/type.xml

The fonts are a bit tricky. ImageMagick will not usually 'see' your system fonts. On OS/X, fonts are stored in a non-standard format.

Use convert -list font to see the fonts ImageMagick currently knows about. It may be blank.

ImageMagick looks for $HOME/.magick/type.xml for the list of fonts. If you are on OS/X, go see the well written tutorial at http://gothick.org.uk/2008/03/14/using-os-x-fonts-in-imagemagick/.

To list only the font names, do convert -list font | grep Font

If you have recently installed a font which is not appearing when using:

convert -list font

You can flush your font cache with:

fc-cache -f -v

Your OS file system will list all your fonts.

But if you are asking about fonts that Imagemagick knows about for use by name, then use convert -list font to see all those fonts listed in its type.xml file.

If that shows nothing, then if you are on a unix-like platform, you can use the perl script by Anthony Thyssen to install your fonts into the type.xml file rather than doing them by hand. See https://www.imagemagick.org/Usage/scripts/imagick_type_gen.

Then doing convert -list font should list the ones that Imagemagick recognizes and you can then use them by name -font fontname . Otherwise, you need to provide the full path to the font file -font path/to/font.suffx.

I find the gnome-font-viewer more useful to see all the fonts visually compared to a list of names returned on the command line.