PHP/Apache 中的 Inkscape 不会将字体呈现为 PNG [英] Inkscape inside PHP/Apache doesn't render fonts to PNG

查看:23
本文介绍了PHP/Apache 中的 Inkscape 不会将字体呈现为 PNG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我今天发现的一个问题类似于这个未解决的问题;虽然不一样,但可能有相同的原因.

An issue I discover today is similar to this unanswered problem; though not the same, it may have the same cause.

我正在使用 inkscape 将 SVG 文件渲染为 PNG 或 PDF.在大多数情况下,我打算使用 Gearman 在后台渲染这些,但现在我正在 PHP/Apache 进程中创建一些缩略图.如果在 Apache 进程中调用inkscape(通过PHP的exec),它似乎无法找到它需要呈现的字体.因此,图形元素呈现良好,但在 PNG 输出中未绘制任何文本元素.

I'm rendering SVG files using inkscape, as either PNG or PDF. For the most part I intend to use Gearman to render these in the background, but for now I am creating some thumbnails inside a PHP/Apache process. It seems that if inkscape is called (via PHP's exec) inside an Apache process, it cannot find the fonts it needs to render. Thus, the graphic elements render fine, but any text elements are not drawn in the PNG output.

我怀疑 Apache 内部的 CLI 环境与我通常的 bash 控制台不同,这意味着无法看到字体.我在 OS X 10.6.8 上.有什么想法吗?

I suspect that the CLI environment from inside Apache is different to my usual bash console in a way that means fonts cannot be seen. I'm on OS X 10.6.8. Any ideas?

根据评论,我在 Apache 和 Gearman 中捕获了 php -i,并将第一个与第二个进行了比较(因此理论上应用差异可以使其工作).结果在这里.

following on from comments, I've captured php -i inside both Apache and Gearman, and diffed the first against the second (so in theory applying the diff would make it work). The result is here.

编辑 2:我已经在两种环境中使用 system 尝试了 convert -list font - 完全没有区别.

Edit 2: I've tried convert -list font in both environments using system - no differences at all.

推荐答案

正如在上面的评论中所确定的,这是由环境差异引起的 - HOME env var 在执行的内部设置不同过程.使用 proc_open 而不是简单的 exec 对上述过程进行了更精确的控制,并明确设置了 env var 解决了这个问题.

As was determined in the comments above, this was caused by an environmental difference - the HOME env var was set differently inside the executed process. Using proc_open instead of simple exec gave more precise control over said process and explicitly setting that env var solved the issue.

这篇关于PHP/Apache 中的 Inkscape 不会将字体呈现为 PNG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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