Question

After entering my username and password into the admin uri of magento I get the following error in system.log

[2017-10-09 00:00:00] main.CRITICAL: Image CAPTCHA requires FT fonts support [] []

there is no such requirement listed by the magento installation guide

Is there a php module I have to enable/install? php -m|grep -i -e 'font' lists nothing... freetype and freetype-devel (v2.4.11)have both been installed to the system.

Was it helpful?

Solution 2

you need to change the php configure script to include --with-freetype-dir=/usr/lib64/ where /usr/lib64 contains the libfreetype.so file.

My final configuration so far looks like:

./configure --with-apxs2=/usr/bin/apxs --enable-bcmath --with-curl --with-gd \
--with-jpeg-dir=/usr/lib64/ --with-png-dir=/usr/lib64/ --with-freetype-dir=/usr/lib64/ \
--enable-intl --enable-mbstring --with-mcrypt --with-mhash --with-openssl \
--with-pdo-mysql --enable-soap --with-xsl --enable-zip --enable-opcache  --with-config-file-path=/etc

then you need to make;make install; and restart the web server.

OTHER TIPS

I found fix for development environment, because I use Mac OS and the apache php doesn't support these fonts and it's a lot of work to get it working and not mess up my system.

open vendor/zendframework/zend-captcha/src/Image.php and add return in the constructor after the parent is called like this

/**
 * Constructor
 *
 * @param  array|\Traversable $options
 * @throws Exception\ExtensionNotLoadedException
 */
public function __construct($options = null)
{
    parent::__construct($options);
    return;

    if (! extension_loaded("gd")) {
        throw new Exception\ExtensionNotLoadedException("Image CAPTCHA requires GD extension");
    }

    if (! function_exists("imagepng")) {
        throw new Exception\ExtensionNotLoadedException("Image CAPTCHA requires PNG support");
    }

    if (! function_exists("imageftbbox")) {
        throw new Exception\ExtensionNotLoadedException("Image CAPTCHA requires FT fonts support");
    }
}

This is almost definitely caused by the underlying system not having FreeType installed (if FreeType is already installed then @user3338098's solution should fix it).

If you come across this problem absolutely do not follow the most upvoted answer (@nacholibre's). Either install the freetype library on your server (usually freetype, libfreetype or similar, will vary depending on distro. apt install freetype should work on Ubuntu), or ask your hosting provider to do so for you. In fact, if you need to ask a managed Magento hosting provider to do this for you then just swap hosting provider.

Never, ever modify code in vendor. If you need to do so then you are doing something very, very, *very* wrong; it completely negates the whole point of using Composer in the first place.

Magento 2.2 has changed the behaviour of the Magento_Captha module to have both the frontend and the admin captcha enabled by default, compared to earlier 2.x versions where the opposite was true

On machines without FreeType built into the PHP GD library (such as OSX High Sierra) this will give the above error when trying to login to the Magento admin system

'main.CRITICAL: Image CAPTCHA requires FT fonts support'

A simple resolution for non-production environments is to disable the behaviour as per earlier Magento versions

vendor/magento/module-captcha/etc/config.xml

   <admin>
        <captcha>
            <type>default</type>
            <enable>0</enable>

...

    <customer>
        <captcha>
            <type>default</type>
            <enable>0</enable>
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top