PHP system() gives different results than terminal, missing fonts
<p><strong>My issue</strong></p>

<p>I am using cairosvg on linux Ubuntu 14.04 LTS with PHP and apache. I am running it with the php function <code>system()</code>. This is the command I am running.</p>

<pre><code>cairosvg -f pdf -o /var/www/dev/output.pdf /var/www/dev/input.svg
</code></pre>

<p>When I run this in terminal, I get the expected results, it generates the pdf file as expected. However when I run this in php using <code>system()</code>, it still generates the pdf file, but does not use the correct fonts.</p>

<p><strong>What I've tried</strong></p>

<p>The fonts are installed. The file permissions for both the folder and the fonts have been set to 777. Apache has been set as a co owner to the font folder and the font. File paths are absolute. <code>echo</code> on <code>system()</code> gives no errors. I have tried using equivalent alternatives to <code>system()</code> as well.</p>

<p><strong>1st Major UPDATE:</strong> I've tried running this ImageMagick command to check the difference in available fonts. <code>convert -list font</code> On Terminal I see my installed fonts, but not on the <code>system()</code> call.</p>

<p><strong>2nd UPDATE</strong> I ran <code>printenv</code> command in both terminal and <code>system()</code> and saw they had different values. I set HOME and USER environment variables using <code>proc_open()</code>, but I get the same results. Code is as follows.</p>

<pre><code>$command = "cairosvg -f pdf -o /var/www/dev/output.pdf /var/www/dev/input.svg";
$descriptorspec = array();
$pipes = array();
$env = array(
    'HOME' =&gt; '/home/ntwdev',
    'USER' =&gt; 'ntwdev',
);
$resource = proc_open(
    $command,
    $descriptorspec,
    $pipes,
    $cwd = null,
    $env
);
</code></pre>

<p><strong>Why are fonts only coming through when I run the command in terminal and not in <code>system()</code></strong></p>