是否有一个PHP库用于将文本绘制为矢量轮廓? [英] Is there a PHP library for drawing text as a vector outline?

查看:129
本文介绍了是否有一个PHP库用于将文本绘制为矢量轮廓?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在PHP中,使用GD将文本绘制到光栅画布上很容易 (根据服务器上保存的TTF文件),并以PNG或JPEG格式输出.

我想做大致相同的事情,但是将文本绘制为矢量轮廓,然后将其输出为 SVG .

(我不想将字体本身嵌入到生成的SVG中,因为该字体未获得许可.)

有没有提供这种功能的PHP库?

解决方案

可以对 inkscape 进行脚本编写./p>

以下命令打开"example.svg",选择文件中的所有形状并将其转换为路径,然后保存并关闭文件.

inkscape --verb EditSelectAll --verb ObjectToPath --verb FileSave --verb FileClose example.svg

In PHP, it's quite easy to use GD to draw text onto a raster canvas in a certain font (according to a TTF file held on the server), and output it as a PNG or JPEG.

I want to do roughly the same thing, but to draw the text as a vector outline and output it as an SVG.

(I do not want to embed the font itself in the resulting SVG, as the font is not licensed for that.)

Is there any PHP library that provides this sort of functionality?

解决方案

It's possible to script inkscape to do this.

The following command opens "example.svg" and selects all shapes in the file and converts them to paths, and then saves and closes the file.

inkscape --verb EditSelectAll --verb ObjectToPath --verb FileSave --verb FileClose example.svg

这篇关于是否有一个PHP库用于将文本绘制为矢量轮廓?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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