I wonder if anyone can help me with what is probably a fairly minor problem.
I wanted to modify the captcha so that I generated words related to the website subject matter.
Actually I am not generating words just pulling words from database, so I randomize a number if the number matches the id I just return the word.
Anyway, I am I copied the CCaptchAction.php into /extensions/sbcaptcha and renamed it SBCaptcha.php
In my controller
public function actions()
{
return array(
// captcha action renders the CAPTCHA image displayed on the contact page
'captcha'=>array(
'class'=>'ext.sbcaptcha.SBCaptchaAction',
'backColor'=>0x000000,
'foreColor'=>0xFFFF00,
'width'=>170,
'height'=>80
// 'fontFile'=>'application.extensions.sbcaptcha.Duality.ttf'
// 'fontFile'=>'ext.sbcaptcha.Duality.ttf'
),
Anyway everything is working, the word is being displayed wiggly like it should. However I seem to be unable to use a different font. Duality.ttf is the original font so I copied that into that directory along with a couple of other fonts I wanted to try. FYI Duality.ttf is the default.
Below is the code that sets the font. This is the same as the YII core file.
if($this->fontFile===null)
$this->fontFile=dirname(__FILE__).'/Duality.ttf';
$offset=2;
$length=strlen($code);
$box=imagettfbbox(30,0,$this->fontFile,$code);
$w=$box[4]-$box[0]-$offset*($length-1);
$h=$box[1]-$box[5];
$scale=min(($this->width-$this->padding*2)/$w,($this->height-$this->padding*2)/$h);
$x=10;
$y=round($this->height*27/40);
for($i=0;$i<$length;++$i)
{
$fontSize=(int)(rand(26,32)*$scale*0.<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/cool.gif' class='bbc_emoticon' alt='8)' />;
$angle=rand(-10,10);
$letter=$code[$i];
$box=imagettftext($image,$fontSize,$angle,$x,$y,$foreColor,$this->fontFile,$letter);
$x=$box[2]-$offset;
In my original code above you can see a couple of approaches that didn’t work, any idea how to point to this file?
doodle