将文本转换为服务器上的路径(svg)? [英] Converting text into path (svg) on server?

查看:244
本文介绍了将文本转换为服务器上的路径(svg)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How can I create text from a TTF font and convert it into a static SVG path? So that anyone could open it in illustrator and see the word (as an .SVG).

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

Our server is Debain, and we primarily use PHP for backend coding.

很高兴使用Imagemagick或Inkscape - 无论如何完成它!

Happy to use Imagemagick or Inkscape - whatever gets it done!

推荐答案

试试这个:


  1. 在Inkscape中创建一个svg模板文件(参见下面的例子)。

  2. 使用文本编辑器打开该文件,并为要更改的变量放置一些占位符标记:字体和文本。

  3. 创建一个网页,以便用户可以选择字体

  4. 在服务器中检索该数据。

  5. 读取模板文件,并使用用户数据更改占位符标记。

  6. 通过命令行调用Inkscape。

  1. Create a svg template file in Inkscape (see an example below).
  2. Open that file with a text editor, and place some placeholder tokens for the variables you want to change: The font, and the text.
  3. Create a web page so the user can select the font and write the text.
  4. Retrieve that data in server.
  5. Read the template file, and change the placeholder tokens with the user data.
  6. Call Inkscape through command line.



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

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

Now, I know, I know, you said you want an svg output... I tried the option:

--export-plain-svg=new_file.svg



<但是根据Inkscape手册页:

But according to the Inkscape man page:

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

Soooo ...无法获得普通的svg导出和导出文本到路径:S ...顺便说一句,这应该填写为错误。

Soooo... can't get plain svg export and exporting text to path :S ... BTW this should be filled as a bug.

您可以提供PDF,或再次致电:

You can serve the PDF, or call again:

inkscape -l new_file.svg new_file.pdf

其中......我知道,非常愚蠢。不,真的,在Inkscape上提交错误:P

Which... I know, is quite stupid. No, really, file a bug on Inkscape :P

这是示例Inkscape模板:

This is the example Inkscape template:

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

亲切的问候。

这篇关于将文本转换为服务器上的路径(svg)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆