In Mangeto 2 We have default Captcha, which is not easily readable.
So how to change/customize Font Name it's Color & Background
Magento builds its Model Captcha which extends from Zend_Captcha_Image
class. So, in your case, we should override Magento\Captcha\Model\DefaultModel
class.
<preference for="Magento\Captcha\Model\DefaultModel"
type="Vendor\Module\Model\DefaultModel"/>
We need to override _generateImage
method.
protected function _generateImage($id, $word)
{
......
$w = $this->getWidth();
$h = $this->getHeight();
$fsize = $this->getFontSize();
......
}
We can remove the generation noise:
Add new font to the default config:
app/code/Company/Module/etc/config.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<captcha translate="label">
<fonts>
<arial>
<label>Arial</label>
<path>CustomFont/Arial.ttf</path>
</arial>
</fonts>
</captcha>
</default>
</config>
Add our custom font: lib/internal/CustomFont/Arial.ttf
Take a look: vendor/magento/module-captcha/Helper/Data.php::getFonts()
to see more details.
vendor\magento\zendframework1\library\Zend\Captcha\Image.php
How to Orverwrite this file? I already removed noise from here. Where to put in app\code
?
For Captcha customise I think you need change in this file :
magento2/vendor/magento/zendframework1/library/Zend/Captcha/Image.php
in Magento ver. 2.4.4 just edit : /vendor/magento/module-captcha/Model/DefaultModel.php