10

如何从 TTF 字体创建文本并将其转换为静态 SVG 路径?这样任何人都可以在 illustrator 中打开它并看到这个词(作为 .SVG)。

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

很高兴使用 Imagemagick 或 Inkscape——不管它做什么!

4

3 回答 3

10

尝试这个:

  1. 在 Inkscape 中创建一个 svg 模板文件(参见下面的示例)。
  2. 使用文本编辑器打开该文件,并为要更改的变量放置一些占位符标记:字体和文本。
  3. 创建一个网页,以便用户可以选择字体并编写文本。
  4. 在服务器中检索该数据。
  5. 阅读模板文件,并使用用户数据更改占位符标记。
  6. 通过命令行调用 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 ...顺便说一句,这应该作为一个错误填充。

您可以提供 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>

亲切的问候。

于 2011-12-07T22:18:05.873 回答
3

您还可以告诉inkscapegui 模式打开您的文件,然后发出命令。以下命令行输入打开一个 svg,选择所有节点,并将它们转换为路径。这将允许您将转换后的 svg 保存回 svg。

inkscape -f your.svg --with-gui --verb EditSelectAll --verb ObjectToPath --verb FileSave --verb FileQuit

请注意,这将覆盖您的文件!

于 2014-05-27T12:39:03.683 回答
0

或者更简单,使用EasySVG,这个库将文本转换为 SVG 定义。然后,您可以将此定义放入路径或其他任何内容中。

该定义基于字体的 SVG 文件,但您可以轻松地将 TTF 文件转换为 SVG...

于 2014-09-24T09:27:15.713 回答