我正在使用 ImageMagick
的 Magick++
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");
但我没有得到要求的结果。
有什么想法吗?
最佳答案
首先使用命令行列出 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 细读选择字体时,您可以选择:
(a) ...要么使用出现在
Font:
标签后面的字体名称,(b) ...或使用实际字体文件的完整路径(显示在
glyphs:
标签后面。
并且不要尝试在 ImageMagick 中仅使用 family:
名称...
如果字体名称或路径包含任何空格,请务必使用引号引起来!
关于c++ - ImageMagick 使用我的真实字体 (Magick++) 转换 SVG,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12051546/