simple-php-captcha错误:找不到字体文件

I am trying to install this CAPTCHA script on my server:

http://www.abeautifulsite.net/blog/2011/01/a-simple-php-captcha-script/

I have uplaoded the files and tried to run the demo. However the CAPTCHA image does not display as it should.

When I try and open the CAPTCHA image directly, I get this error

Fatal error: Uncaught exception 'Exception' with message 'Font file not found: ' in /home/website/public_html/simple-php-captcha/simple-php-captcha.php:125 Stack trace: #0 {main} thrown in /home/website/public_html/simple-php-captcha/simple-php-captcha.php on line 125

Code below:

Line 125: if( !file_exists($font) ) throw new Exception('Font file not found: ' . $font);

The font file path is set earlier in the code:

$captcha_config = array(
    'code' => '',
    'min_length' => 5,
    'max_length' => 5,
    'png_backgrounds' => array(dirname(__FILE__) . '/default.png'),
    'fonts' => array(dirname(__FILE__) . '/times_new_yorker.ttf'),
    'characters' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789',
    'min_font_size' => 24,
    'max_font_size' => 30,
    'color' => '#000',
    'angle_min' => 0,
    'angle_max' => 15,
    'shadow' => true,
    'shadow_color' => '#CCC',
    'shadow_offset_x' => -2,
    'shadow_offset_y' => 2
);

$font = $captcha_config['fonts'][rand(0, count($captcha_config['fonts']) - 1)];

I have checked and all the required files are in the folder.

Does anyone know how to fix this error?

I've just found out that simple php captcha does no work with page caching and the exception "font file not found" is thrown some what falsely. I made sure that the page that has CAPTCHA image on it is not cached and problem is solved.

In my particular case, I have a page /register/ which has a CAPTCHA image. I'm using W3 Total Cache to do page-caching for my WordPress website.

Hope this helps.