title: imagettftext cannot open font file
body: <p>Using the <a href="http://php.net/manual/en/function.imagettftext.php" rel="noreferrer">example from php.net</a> I get a warning, and the image is not rendered correctly. I supply a full path to the .ttf file like so: <code>/var/www/public/myfont.ttf</code></p>
  
  <pre><code>PHP Warning:  imagettftext() [&lt;a href='function.imagettftext'&gt;function.imagettftext&lt;/a&gt;]: Could not find/open font in &lt;phpfile&gt;
  </code></pre>
  
  <p>I am using a custom .ttf font found <a href="http://www.1001fonts.com/search.html?query=Unmasked%20BB" rel="noreferrer">here</a>. I can open the file fine in Ubuntu as a valid font file. I also attempted other fonts, with the same result.</p>
  
  <p>I am using Ubuntu 10.04 LTS 32 bit, with apache2, php5, freetype6 and php5-gd installed. I also attempted to chmod 777 file and folder with ttf file, with the same result.</p>
  
  <p>How can I get the example working using a custom ttf font file?</p>
  
  <p>*Edit: The code I'm using:</p>
  
  <pre><code>&lt;?php
  // File is: /var/www/public/test.php
  // Apart from $font variable, it's copy-pasted from php.net
  
  // Set the content-type
  header('Content-Type: image/png');
  
  // Create the image
  $im = imagecreatetruecolor(400, 30);
  
  // Create some colors
  $white = imagecolorallocate($im, 255, 255, 255);
  $grey = imagecolorallocate($im, 128, 128, 128);
  $black = imagecolorallocate($im, 0, 0, 0);
  imagefilledrectangle($im, 0, 0, 399, 29, $white);
  
  // The text to draw
  $text = 'Testing...';
  // Replace path by your own font path
  $font = '/var/www/public/UnmaskedBB.ttf';
  
  // Add some shadow to the text
  imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);
  
  // Add the text
  imagettftext($im, 20, 0, 10, 20, $black, $font, $text);
  
  // Using imagepng() results in clearer text compared with imagejpeg()
  imagepng($im);
  imagedestroy($im);
  ?&gt;
  </code></pre>
  
  <p>Output from phpinfo();</p>
  
  <pre><code>[gd]
  GD Support  enabled
  GD Version  2.0
  FreeType Support    enabled
  FreeType Linkage    with freetype
  FreeType Version    2.3.11
  T1Lib Support   enabled
  GIF Read Support    enabled
  GIF Create Support  enabled
  JPEG Support    enabled
  libJPEG Version     6b
  PNG Support     enabled
  libPNG Version  1.2.42
  WBMP Support    enabled 
  </code></pre>
  
  <p>Testing <code>is_file</code> and <code>is_readable</code>:</p>
  
  <pre><code>$font = realpath('./').'/UnmaskedBB.ttf';
  echo "Font: ".$font; // /var/www/public/UnmaskedBB.ttf
  echo "Is file? ".is_file($font); // 1
  echo "Is readable? ".is_readable($font); // 1
  </code></pre>