为什么imagemagick的字体列表是空的? [英] why font list is empty for imagemagick?

查看:19
本文介绍了为什么imagemagick的字体列表是空的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 ImageMagick 向图像添加一些文本.但是我发现它总是说我指定的字体不存在.仔细阅读手册后,我注意到我可以使用 convert -list font 来输出所有可用的字体,但在尝试后我发现可用字体的列表是空的.

I am trying to use ImageMagick to add some text to an image. But I found it always said that my specified font doesn't exist. After reading the manual carefully I noticed that I can use convert -list font to output all the available fonts, but after trying I figured out that the list of available font is empty.

这是我得到的:

shell$ convert -list font
shell$ 

感谢您提供任何提示.

推荐答案

我只是设法告诉 ImageMagick 我的 OSX 系统上的字体是这样的:

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>

如何为您的 type.xml 文件找到正确的文件夹

存储 type.xml 的文件夹可能因系统和版本而异.最近的用户配置文件夹似乎是 ~/.config/ImageMagick,但我知道找到它的最好方法是运行以下命令来查看 ImageMagick 的位置看着:

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" ...

所以有很多地方可以插入字体.通常,如果您选择以 /etc/usr/local 开头的文件夹,则所有用户和 Web 服务器中的脚本都可以使用字体 - 如果你想要那个.另一方面,如果您只是一个用户,您可能更愿意将字体配置文件保存在您的登录目录中,例如~/.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.

这篇关于为什么imagemagick的字体列表是空的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆