/** * @param String $code * @return gotcha_GotchaPng */ protected function generate($code) { $img = new gotcha_GotchaPng($this->width, $this->height); if ($img->create()) { //fill the background color. $img->apply(new gotcha_GradientEffect()); //Apply the Grid. $img->apply(new gotcha_GridEffect(2)); $img->apply(new gotcha_LineEffect()); //Add the text. $t = new gotcha_TextEffect($code, $this->fontSize, $this->fontDepth); $t->addFont(f_util_FileUtils::buildAbsolutePath(FRAMEWORK_HOME, 'libs', 'gotcha', 'SFTransRoboticsExtended.ttf')); $t->addFont(f_util_FileUtils::buildAbsolutePath(FRAMEWORK_HOME, 'libs', 'gotcha', 'arialbd.ttf')); $t->addFont(f_util_FileUtils::buildAbsolutePath(FRAMEWORK_HOME, 'libs', 'gotcha', 'comic.ttf')); $t->addFont(f_util_FileUtils::buildAbsolutePath(FRAMEWORK_HOME, 'libs', 'gotcha', 'britanic.ttf')); // repeat the process for as much fonts as you want. Actually, the more the better. // A font type will be randomly selected for each character in the text code. $img->apply($t); //Add more dots $img->apply(new gotcha_DotEffect()); return $img; } throw new Exception("Could not generate CAPTCHA image."); }