php – 在服务器上将文本转换为路径(svg)?

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了php – 在服务器上将文本转换为路径(svg)?脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
如何从TTF字体创建文本并将其转换为静态SVG路径?所以任何人都可以在插画中打开它并看到这个词(作为.SVG).

我们的服务器是Debain,我们主要使用PHP进行后端编码.

很高兴使用ImageMagick或InkscaPE – 无论如何完成它!

试试这个:

>在Inkscape中创建一个svg模板文件(参见下面的示例).
>使用文本编辑器打开该文件,并为要更改的变量放置一些占位符标记:字体和文本.
>创建一个网页,以便用户可以选择字体并编写文本.
>在服务器中检索该数据.
>读取模板文件,并使用用户数据更改占位符标记.
>通过命令行调用Inkscape.

inkscape template.svg --export-text-to-path --export-id=maintext --export-pDF=new_file.pdf

现在,我知道,你说你想要一个svg输出……我尝试了这个选项:

--export-plain-svg=new_file.svg

但根据Inkscape手册页:

-T,--export-text-to-path
    Convert text objects to paths on export,where applicable (for PS,EPS,and PDF export).

Soooo …无法获得普通的svg导出和导出文本到路径:S … BTW这应该填充为一个bug.

您可以提供PDF,或再次致

inkscape -l new_file.svg new_file.pdf

哪个……我知道,这是非常愚蠢的.不,真的,在Inkscape上提出错误:P

这是示例Inkscape模板:

<?XMl version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created wITh Inkscape (http://www.inkscape.org/) -->

<svg
   xMLns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-Syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   version="1.1"
   width="440.29297"
   height="39.824219"
   id="svg2">
  <defs
     id="defs4" />
  <Metadata
     id="Metadata7">
    <rdf:RDF>
      <cc:Work
         rdf:about="">
        <dc:format>image/svg+xml</dc:format>
        <dc:type
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
        <dc:title></dc:title>
      </cc:Work>
    </rdf:RDF>
  </Metadata>
  <text
     x="-3.4374955"
     y="30.390625"
     id="maintext"
     xml:space="PReserve"
     style="font-Size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:[FONT_PLACEHOLDER]"><tspan
       x="-3.4374955"
       y="30.390625"
       id="tspan3006"
       style="fill:#000000">[TEXT_PLACEHOLDER]</tspan></text>
</svg>

亲切的问候.

脚本宝典总结

以上是脚本宝典为你收集整理的php – 在服务器上将文本转换为路径(svg)?全部内容,希望文章能够帮你解决php – 在服务器上将文本转换为路径(svg)?所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。