【问题标题】:How can i increase the font size of codeigniter captcha helper我怎样才能增加codeigniter验证码助手的字体大小
【发布时间】:2013-03-01 14:34:16
【问题描述】:

我正在使用 codeigniter *capctha* 助手。问题是我不能增加字母的字体大小。我试图做到这一点

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;
}

但是没有任何反应,如何更改字体大小,请帮助。 提前致谢。

【问题讨论】:

    标签: php codeigniter captcha helper


    【解决方案1】:

    您正在更改正确的参数,无论是在核心文件还是应用程序/帮助文件中。

    仔细检查您使用的字体。有些字体只有一种尺寸,就是这样。默认字体文件(texb.ttf)只有一种大小(?我认为...)。

    我正在使用以下配置:

    //----- 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);
    

    选择一个字体文件并将其放在字体文件夹中并尝试一下。

    【讨论】:

    • 是的,默认字体(texb.ttf)似乎只有一种大小。我尝试更改为另一种字体,一切运行良好。
    【解决方案2】:

    您可以在 captha 的 font_path 中使用“真实类型”字体以获得更大的尺寸。尝试在font_path 中设置path/to/your/ttfont.ttf,然后将更大的值传递给font_size。它应该工作!

    【讨论】:

      猜你喜欢
      • 2019-11-28
      • 2011-01-10
      • 2022-01-23
      • 1970-01-01
      • 2012-10-28
      • 2011-07-08
      • 2017-04-17
      • 2011-10-27
      相关资源
      最近更新 更多