【问题标题】:How do you set ImageMagick font path for SVG conversion?如何为 SVG 转换设置 ImageMagick 字体路径?
【发布时间】:2015-06-23 17:36:05
【问题描述】:

我在这里有一个使用 Lobster 的测试 SVG:

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

这在浏览器中渲染得很好,但是在 ImageMagick(使用 php)中转换为 PNG 时,字体不会渲染。

我知道你可以使用 setFont 命令设置单个字体,但是 SVG 可能包含多个字体。

在这种情况下,有没有办法为 ImageMagick 设置字体目录?

【问题讨论】:

    标签: php css svg fonts


    【解决方案1】:

    从手册看来,没有办法导入字体目录。
    可能是我错了。

    替代品

    手册中有ImagickDraw::setFont 允许您使用多种字体。

    考虑到使用这种方法你必须绘制文本,它不完全是为了转换,但它可能有用。

    【讨论】:

    • 感谢您的信息。这似乎是一个问题,因为我将不得不采用具有 N 种字体的 SVG 并与其他图像构建复合材料。这是 GD 可以轻松做到的事情吗?
    猜你喜欢
    • 2020-11-02
    • 1970-01-01
    • 1970-01-01
    • 2019-08-26
    • 2020-05-15
    • 2019-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多