Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
358 views
in Technique[技术] by (71.8m points)

Inkscape inside PHP/Apache doesn't render fonts to PNG

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

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.

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?

Edit: 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.

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...