4

How do I change the font used by the sign-up CAPTCHA in Magento? It only has the option for LibLibertine by default in the CAPTCHA settings in the Configuration menu. Is it possible to add other fonts? Will another font make the text easier to read or do I need to look at something else?

I find the default hard to read and often have to type the CAPTCHA multiple times before I get it right.

1

1 Answer 1

3

If you take a look at app/code/core/Mage/Captcha/etc/config.xml you'll find:

    <captcha  translate="label">
        <fonts>
            <linlibertine>
                <label>LinLibertine</label>
                <path>lib/LinLibertineFont/LinLibertine_Bd-2.8.1.ttf</path>
            </linlibertine>
        </fonts>

Further in you'll find getFonts() in app/code/core/Mage/Captcha/Helper/Data.php

/**
 * Get list of available fonts
 * Return format:
 * [['arial'] => ['label' => 'Arial', 'path' => '/www/magento/fonts/arial.ttf']]
 *
 * @return array
 */
public function getFonts()
{
    $node = Mage::getConfig()->getNode(Mage_Captcha_Helper_Data::XML_PATH_CAPTCHA_FONTS);
    $fonts = array();
    if ($node) {
        foreach ($node->children() as $fontName => $fontNode) {
           $fonts[$fontName] = array(
               'label' => (string)$fontNode->label,
               'path' => Mage::getBaseDir('base') . DS . $fontNode->path
           );
        }
    }
    return $fonts;
}

With the above, adding a compatible .ttf font to your lib/ folder and adding the font option to the configuration XML nodes will add a new font to the available list.

Magento does use Zend Libraries Zend_Captcha, you'll find this in lib/Zend/Captcha

Keep in mind the LinLibertine font is used with PDF generation so removing it or replacing it may cause other issues.

Also I have not tested any of this but general observations but hopefully will lead you in the right direction.

Hope this helps!

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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