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.

For docker users - update for Magento 2.4, for those using official php docker images - I had to use --with-freetype rather than @cgalvaojr answer --with-freetype-dir, like this:

FROM php:7.4-fpm

ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update -qq && apt-get -y upgrade && apt-get update -qq

# apt packages we might need:
RUN apt-get install -y -qq wget git ssh mariadb-client unzip vim rsync nginx jq

# extensions already in: ctype curl hash iconv pic ftp mbstring mysqlnd argon2 sodium pdo_sqlite sqlite3 libedit openssl zlib pear
# official Magento 2.4 required exts: bcmath ctype curl dom gd hash iconv intl mbstring openssl pdo_mysql simplexml soap xsl zip sockets

# for php extensions - not needed, all preinstalled except for gd:
RUN apt-get install -y -qq libjpeg62-turbo-dev libpng-dev libxml2-dev libxslt-dev libsodium-dev libzip-dev libfreetype6-dev
RUN docker-php-ext-configure gd --with-freetype --with-jpeg
RUN docker-php-ext-install bcmath gd intl pdo_mysql simplexml soap xsl zip sockets
RUN docker-php-ext-enable bcmath gd intl pdo_mysql simplexml soap xsl zip sockets

For me (using docker) solves problem with:

FROM php:7.2.0-fpm-stretch

RUN apt-get update --fix-missing libfreetype6-dev
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/
&& docker-php-ext-install gd

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