4

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.

4

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");
    }
}
  • 3
    This is an absolutely terrible answer; you should never modify anything in vendor. – chrBrd Nov 11 '18 at 23:19
  • After a couple of hours digging only that helped, note that I changed the file only on my machine, the prosuction server was with the oeiginal file. – nacholibre Nov 12 '18 at 4:58
  • 1
    Unless it's purely for debugging modifications to check what core code is doing (even then with a decent IDE this shouldn't be necessary); you should_ absolutely_ not be touching anything in vendor. You certainly shouldn't recommend others do without adding huge caveats. If you need to modify code in vendor to get something to work then your code is broken and your solution is wrong. – chrBrd Nov 12 '18 at 22:08
  • I don't recommend to do it in production, the first line says "I found fix for development environment", because most of the time the dev environment is different than production. For example I'm developing on Mac, but the production is on Linux, in order to use exactly the same software, versions and configs I need to invest a lot of time to setup some kind of container which I don't want to do. – nacholibre Nov 14 '18 at 12:56
  • 1
    Learning how to use Docker for a simple dev env takes about a week. If you're so unwilling to spend that amount of time learning how to use the tools of your trade in order to ensure a consistent development environment between the platforms you work with then I sincerely hope I never have to inherit a codebase you've touched. I doubt you even require containers, just a single, simple dependecy installed. Advising people to do critically stupid things like edit anything in vendor, regardless of whether they're in dev or prod is just fundamentally poor advice. – chrBrd Nov 15 '18 at 0:15
3

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.

  • On Ubuntu 14, I needed to first install libfreetype-dev: sudo apt-get install libfreetype6-dev, and then my config directive was: --with-freetype-dir=/usr/lib/x86_64-linux-gnu/' – Andrew C. Stayart Jan 17 '18 at 15:46
  • @user3338098 Please consider accepting your own answer as the accepted answer to this question. It also worked for me thank you. – Darren Felton Jun 28 at 20:46
  • had to add the --with-config-file-path since the default is /usr/local/lib/php.ini which is the last place anyone would ever look. – user3338098 Jul 5 at 20:05
0

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.

-1

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>
  • 1
    I've tried this, but it doesn't work. – nacholibre Nov 3 '17 at 19:54
  • 1
    You can alternatively disable the module locally as follows bin/magento module:disable Magento_Captcha – Judder May 3 '18 at 16:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.