duanfangfei5558 2015-04-17 03:05
浏览 226

如何为SVG转换设置ImageMagick字体路径?

I've got a test SVG here using Lobster:

<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="2400" height="3200" xmlns:xlink="http://www.w3.org/1999/xlink">
    <defs>
        <style>
            @import url('http://fonts.googleapis.com/css?family=Lobster');
        </style>
    </defs>
    <text id="SvgjsText1046" font-family="Lobster" fill="#000000" font-size="30px" stroke-width="0" font-style="" font-weight="" text-decoration=" " x="859.9871134019216" y="476.38530927854697" transform="rotate(0 1214.8671520099174 1164.5108891121047) translate(-9360.999092988961 -5185.475896759851) scale(11.885045772324295 11.885045772324297) ">
        <tspan id="SvgjsTspan1072" dy="29">TEST</tspan>
        <tspan id="SvgjsTspan1073" dy="29">TEST</tspan>
        <tspan id="SvgjsTspan1074" dy="29">TEST</tspan>
    </text>
</svg>

This renders fine in the browser, but when converting to a PNG in ImageMagick (using php), the font doesn't render.

I know you can use the setFont command to set a single font, but the SVG may contain multiple fonts.

In this instance, is there any way to set a font directory for ImageMagick?

  • 写回答

1条回答 默认 最新

  • dtkvlj5386 2015-04-17 04:41
    关注

    From the manual it seems that there is no way to import a font directory.
    May be i'm wrong btw.

    Alternatives

    In the manual there is ImagickDraw::setFont which allow you to use multiple fonts.

    Consider that with this method you have to draw the text, It's not exactly for conversion but may be it can be usefull.

    评论

报告相同问题?

悬赏问题

  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services