I just managed to tell ImageMagick about the fonts on my OSX system like this:
# Make a new directory for ImageMagick local settings and cd into it
mkdir ~/.magick
cd ~/.magick
# Grab script to find all fonts on system and store them in a config file
curl -L http://www.imagemagick.org/Usage/scripts/imagick_type_gen > type_gen
# Run script, telling it where my fonts are and create "type.xml" file with list
find /System/Library/Fonts /Library/Fonts ~/Library/Fonts -name "*.[to]tf" | perl type_gen -f - > type.xml
# Go to ImageMagick config folder - see note at end to find correct folder
cd /usr/local/Cellar/imagemagick/6.8.9-1/etc/ImageMagick-6
# Edit system config file called "type.xml" and add line near end to tell IM to look at local file we made in earlier step
<typemap>
<include file="type-ghostscript.xml" />
<include file="~/.magick/type.xml" /> ### THIS LINE ADDED ###
</typemap>
How to find the correct folder for your type.xml
file
The folder where type.xml
is stored can vary enormously between systems and versions. Most recently the user configuration folder seems to be ~/.config/ImageMagick
, but the best way I know of finding it is to run the following command to see where ImageMagick is looking:
convert -debug configure -list font 2>&1 | grep -E "Searching|Loading"
Searching for configure file: "/usr/local/Cellar/imagemagick/7.0.11-6/share/ImageMagick-7/type.xml"
Searching for configure file: "/usr/local/Cellar/imagemagick/7.0.11-6/lib/ImageMagick//config-Q16HDRI/type.xml"
Searching for configure file: "/usr/local/Cellar/imagemagick/7.0.11-6/etc/ImageMagick-7/type.xml"
Searching for configure file: "/usr/local/Cellar/imagemagick/7.0.11-6/share/doc/ImageMagick-7/type.xml"
Searching for configure file: "/Users/username/.config/ImageMagick/type.xml"
Loading type configure file "/usr/local/Cellar/imagemagick/7.0.11-6/etc/ImageMagick-7/type.xml" ...
Loading type configure file "/usr/local/Cellar/imagemagick/7.0.11-6/etc/ImageMagick-7/type-ghostscript.xml" ...
Loading type configure file "/Users/username/.config/ImageMagick/type.xml" ...
So there are lots of places you could insert the fonts. In general, if you choose a folder starting with /etc
or /usr/local
the fonts will be available for all users and for scripts in your web server to use - if you want that. On the other hand, if you are just a single user, you may prefer to keep the font config file in your login directory, e.g. ~/.config/ImageMagick/type.xml
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…