'Captcha Helper Codeigniter Error - imagettftext(): Could not find/open font

please help me solve this problem. I want to use the captcha in my login page using captcha helper in CodeIgniter, but got some error like this :

A PHP Error was encountered

Severity: Warning

Message: imagettftext(): Could not find/open font

Filename: helpers/captcha_helper.php

=============================================

this is my controller :

public function login() {

    $data['captcha'] = $this->set_captcha();
    $this->load->view('access/login', $data);

}

public function set_captcha() {

    $vals = array(
        'img_path'      => './assets/img/captcha/',
        'img_url'       => base_url('assets/img/captcha'),
        'font_path'     => './assets/fonts/Kalam-Regular.ttf',
        'img_width'     => 175,
        'img_height'    => 55,
        'expiration'    => 3600,
        'word_length'   => 5,
        'font_size'     => 17,
        'pool'          => '0123456789abcdefghijklmnopqrstuvwxyz',

        // White background and border, black text and red grid
        'colors'        => array(
            'background' => array(255, 255, 255),
            'border' => array(255, 255, 255),
            'text' => array(160, 160, 160),
            'grid' => array(255, 183, 206)
        )
    );

    $cap = create_captcha($vals);

    return $cap['image'];

}

and then I just echo the captcha variable in the view.

the problem is only show in windows (XAMPP) but not in my ubuntu server. please tell me if any duplicate of this post, I have searched the list of posts & google but did not find the same problem.



Solution 1:[1]

it happens to me when i start using xampp for test purpose, so what i did was... i did change to 'font_path' => base_url('system/fonts/texb.ttf'),

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jeyglo