title: imagettftext(): Could not find/open font error message
body: <p>I'm trying to read a captcha image in a form. </p>
  
  <p>Here is the form code:</p>
  
  <pre><code>&lt;form class="login" method="POST" action=""&gt;
      &lt;p class="title"&gt;Are you human?&lt;/p&gt;
      &lt;div id="captchaimage"&gt;
          &lt;img src="generate.php"&gt;
      &lt;/div&gt;
      &lt;input type="text" name="scr" size="6" placeholder="Write what you see here" autofocus/&gt;
      &lt;input class="submititon" type="submit" value="Submit" name="submit"&gt;&lt;/input&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>And this is the <code>generate.php</code> file:</p>
  
  <pre><code>&lt;?php 
  session_start();
  //header('Content-type: image/jpeg');
  $text = $_SESSION['scr'];
  $font_size = 26;
  $image_width = 100;
  $image_height = 40;
  
  $image = imagecreate($image_width, $image_height);
  imagecolorallocate($image,255,255,255);
  $text_color = imagecolorallocate($image,0,0,0);
  
  for($x=1;$x&lt;=30;$x++){
      $x1 = rand(1, 100);
      $y1 = rand(1, 100);
      $x2 = rand(1, 100);
      $y2 = rand(1, 100);
  
      imageline($image, $x1, $y1 ,$x2 ,$y2, $text_color);
  }
  
  imagettftext($image, $font_size, 0, 15, 30, $text_color, 'font.ttf', $text);
  imagejpeg($image);
  ?&gt;
  </code></pre>
  
  <p>As you can see I have commented out the <code>header()</code> to see what error this page returns. And the error is this:</p>
  
  <p><strong>Warning: imagettftext(): Could not find/open font on line 25</strong></p>
  
  <p>Line 25:</p>
  
  <pre><code>imagettftext($image, $font_size, 0, 15, 30, $text_color, 'font.ttf', $text);
  </code></pre>
  
  <p>I don't know why this error happens because the <code>font.ttf</code> file is placed correctly in the same directory. </p>
  
  <p>So what is going on here guys ?!</p>