ImageMagick使用我的真实字体转换SVG(Magick ++)

时间:2012-08-21 09:05:19

标签: c++ c svg imagemagick imagemagick-convert

我正在使用Magick++ ImageMagick API。我无法找到如何使用我的字体设置渲染svg到栅格。 this is my svg

目标是实现

的模拟
convert.exe -font C:\Fonts\RoadSymbols.ttf C:\ua_03.svg C:\1.png

但使用Magick++ API。

我尝试设置这样的字体:

Magick::Image svgImage("C:\\ua_03.svg");
svgImage.magick("png");
svgImage.font("@C:\\Fonts\\RoadSymbols.ttf");
svgImage.write("C:\\1.png");

但我没有得到所需的结果。

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

首先使用命令行列出ImageMagick已知的所有字体:

 convert.exe -list font

你会看到这样的事情:

Path: /opt/local/etc/ImageMagick/type-ghostscript.xml
Font: AvantGarde-Book
  family: AvantGarde
  style: Normal
  stretch: Normal
  weight: 400
  glyphs: /opt/local/share/fonts/urw-fonts/a010013l.pfb
Font: AvantGarde-BookOblique
  family: AvantGarde
  style: Oblique
  stretch: Normal
  weight: 400
  glyphs: /opt/local/share/fonts/urw-fonts/a010033l.pfb
Font: AvantGarde-Demi
  family: AvantGarde
  style: Normal
  stretch: Normal
  weight: 600
  glyphs: /opt/local/share/fonts/urw-fonts/a010015l.pfb
Font: AvantGarde-DemiOblique
  family: AvantGarde
  style: Oblique
  stretch: Normal
  weight: 600
  glyphs: /opt/local/share/fonts/urw-fonts/a010035l.pfb
[...]

然后,当从该列表中选择ImageMagick的peruse字体时,您可以选择:

  • (a)...要么使用Font:标记后面显示的字体名称,

  • (b)...或使用实际字体文件的完整路径(显示在glyphs:标记后面。

请勿尝试仅将family:名称与ImageMagick一起使用...

请确保在任何字体名称或路径周围使用引号,如果它们包含任何空格!