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

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

问题描述

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



这是我得到的:

$ p $ shell $ convert -list字体
shell $

感谢您的任何提示。 b

解决方案

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

 #为ImageMagick本地设置制作一个新目录,并将其放入光盘
mkdir〜/ .magick
cd〜/ .magick

#抓取脚本来查找系统中的所有字体并将其存储在配置文件中
curl http://www.imagemagick.org/Usage/scripts/imagick_type_gen> type_gen

#运行脚本,告诉它我的字体在哪里,并用列表
find / System / Library / Fonts / Library / Fonts〜/ Library / Fonts创建type.xml名称*。[to] tf| perl type_gen -f - > type.xml

#转到ImageMagick config文件夹 - 查看结尾的注释找到正确的文件夹
cd /usr/local/Cellar/imagemagick/6.8.9-1/etc/ImageMagick- 6

#编辑名为type.xml的系统配置文件,并在最后添加行,告诉IM查看我们在前面的步骤

< include file =type-ghostscript.xml/>
< include file =〜/ .magick / type.xml/> ###这行添加###



如何为 type.xml找到正确的文件夹
$ type.xml 所在的文件夹在系统和版本之间可能有很大的不同。我知道找到它的最好方法是运行以下命令来查看 ImageMagick 正在查找的位置:

  convert -debug configure -list font 2>& 1 | grep -ESearching | Loading

搜索配置文件:/usr/local/Cellar/imagemagick/6.9.5-0/share/ImageMagick-6/type.xml
搜索配置文件:/usr/local/Cellar/imagemagick/6.9.5-0/lib/ImageMagick//config-Q16/type.xml
搜索配置文件:/ usr / local /地下室/ imagemagick / 6.9.5-0 / etc / ImageMagick-6 / type.xml
搜索配置文件:/usr/local/Cellar/imagemagick/6.9.5-0/share/doc/ImageMagick -6 / type.xml
搜索配置文件:/Users/mark/.config/ImageMagick/type.xml
搜索配置文件:/Users/mark/.magick/type .xml
加载类型配置文件/usr/local/Cellar/imagemagick/6.9.5-0/etc/ImageMagick-6/type.xml...
加载类型配置文件/ usr / local / Cellar / imagemagick / 6.9.5-0 / etc / ImageMagick-6 / type-apple.xml...
加载类型配置文件/usr/local/Cellar/imagemagick/6.9.5 -0 / etc / ImageMagick-6 / type-ghostscript.xml...
加载类型配置文件/ Users / mark / .magick / type.xml...

所以有很多地方可以插入字体。一般来说,如果你选择一个以 / etc / usr / local 开头的文件夹,用户和您的Web服务器中的脚本使用 - 如果你想要的话。另一方面,如果你只是一个用户,你可能更喜欢将字体配置文件保存在登录目录中,例如 $ HOME / .magick / type.xml


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.

This is what I get:

shell$ convert -list font
shell$ 

Thanks for any kind of tips.

解决方案

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 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. 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/6.9.5-0/share/ImageMagick-6/type.xml"
  Searching for configure file: "/usr/local/Cellar/imagemagick/6.9.5-0/lib/ImageMagick//config-Q16/type.xml"
  Searching for configure file: "/usr/local/Cellar/imagemagick/6.9.5-0/etc/ImageMagick-6/type.xml"
  Searching for configure file: "/usr/local/Cellar/imagemagick/6.9.5-0/share/doc/ImageMagick-6/type.xml"
  Searching for configure file: "/Users/mark/.config/ImageMagick/type.xml"
  Searching for configure file: "/Users/mark/.magick/type.xml"
  Loading type configure file "/usr/local/Cellar/imagemagick/6.9.5-0/etc/ImageMagick-6/type.xml" ...
  Loading type configure file "/usr/local/Cellar/imagemagick/6.9.5-0/etc/ImageMagick-6/type-apple.xml" ...
  Loading type configure file "/usr/local/Cellar/imagemagick/6.9.5-0/etc/ImageMagick-6/type-ghostscript.xml" ...
  Loading type configure file "/Users/mark/.magick/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. $HOME/.magick/type.xml.

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

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