using-zf3-book-samples icon indicating copy to clipboard operation
using-zf3-book-samples copied to clipboard

Captcha font issue

Open zabimca opened this issue 5 years ago • 8 comments

Hi, I'm getting warning error in Reset Password page and couldnt able to reset password.

Warning: imageftbbox(): Could not find/open font in C:\xampp\htdocs\userdemo\vendor\zendframework\zend-captcha\src\Image.php on line 510

Warning: imagefttext(): Could not find/open font in C:\xampp\htdocs\userdemo\vendor\zendframework\zend-captcha\src\Image.php on line 513 reset_password

Screenshot attached for reference. Please help me on that

zabimca avatar Apr 12 '19 06:04 zabimca

make sure you have created the folder: captcha: public/img/captcha and the folder font inside data: AppName/data/font/thorne_shade.ttf

then: setup the captcha form element inside the PasswordResetForm.php ... .. 'captcha' => [ 'class' => 'Image', 'imgDir' => 'public/img/captcha', 'suffix' => '.png', 'imgUrl' => 'img/captcha/', 'imgAlt' => 'CAPTCHA Image', 'font' => './data/font/thorne_shaded.ttf', .. .. ..

I resolved this problem with the after-mentioned. Good Luck.

kristofermagic avatar Apr 12 '19 15:04 kristofermagic

make sure you have created the folder: captcha: public/img/captcha and the folder font inside data: AppName/data/font/thorne_shade.ttf

then: setup the captcha form element inside the PasswordResetForm.php ... .. 'captcha' => [ 'class' => 'Image', 'imgDir' => 'public/img/captcha', 'suffix' => '.png', 'imgUrl' => 'img/captcha/', 'imgAlt' => 'CAPTCHA Image', 'font' => './data/font/thorne_shaded.ttf', .. .. ..

I resolved this problem with the after-mentioned. Good Luck.

Above mentioned code is already there in my code. No Luck.

zabimca avatar Apr 15 '19 05:04 zabimca

have you active the GD php extension?

kristofermagic avatar Apr 15 '19 14:04 kristofermagic

have you active the GD php extension?

Yes it is active.

zabimca avatar Apr 17 '19 08:04 zabimca

hola alguien ya soluciono este error es que no puedo pasar de este error igual tengo activa la extensión gd y el archivo PasswordResetForm.php esta igual. por favor soy nuevo en esto

JimTzoy avatar Sep 14 '19 04:09 JimTzoy

I was struggling also with this in Windows. I found out that the 'font' key should be made with realpath() (I believe is an issue with the imagefbbox function). Also, as I did not setup VirtualHost, I had to add './' in the 'imgDir' key

$this->add([ 'type' => 'captcha', 'name' => 'captcha', 'options' => [ 'label' => 'Human check', 'captcha' => [ 'class' => 'Image', 'imgDir' => './public/img/captcha', //added ./ 'suffix' => '.png', 'imgUrl' => 'img/captcha/', 'imgAlt' => 'CAPTCHA Image', 'font' => realpath('./data/font/thorne_shaded.ttf'), //added realpath 'fsize' => 24, 'width' => 350, 'height' => 100, 'expiration' => 600, 'dotNoiseLevel' => 40, 'lineNoiseLevel' => 3 ], ], ]);

Hope this helps!

heldersoares avatar Nov 28 '19 17:11 heldersoares

@heldersoares

thank you friend, excellent contribution it worked correctly

JimTzoy avatar Nov 29 '19 17:11 JimTzoy

:)

heldersoares avatar Dec 02 '19 09:12 heldersoares