How can i increase the font size of codeigniter captcha helper

巧了我就是萌 提交于 2019-12-23 10:55:34

问题


I am using the codeigniter *capctha* helper. The thing is I can not increase the font size of letters. I tried to do it by

if ($use_font == FALSE)
{
    $font_size = 6;
    $x = rand(0, $img_width/($length/2));
    $y = 0;
}
else
{
    $font_size = 20;
    $x = rand(0, $img_width/($length/1.5));
    $y = $font_size+2;
}

but nothing happens, how can change the font size, please help. Thanks in advance.


回答1:


You are changing the correct parameter, whether in the core file or the application/helpers file.

Double check the font that you are using. Some fonts have one size and that is it. The default font file (texb.ttf) has only one size (? I think...).

I am using the following configuration:

//----- Captcha Implementation -----
$this->load->helper('captcha');

$captchaSetup = array(
    'img_path'   => './captcha/',
    'img_url'    => base_url()."captcha/",
    'font_path'  => './assets/fonts/E004007T.TTF',
    'img_width'  => 250,
    'img_height' => 50,
    'expiration' => 7200
);

$capData['cap'] = create_captcha($captchaSetup);

Pick a font file and place it in the fonts folder and try it out.




回答2:


You may use "true type" fonts in captha's font_path to get a bigger size. Try to set path/to/your/ttfont.ttf in font_path and then pass a greater value to font_size. It should work!



来源:https://stackoverflow.com/questions/15389029/how-can-i-increase-the-font-size-of-codeigniter-captcha-helper

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!