Search the Community
Showing results for tags 'true type font'.
-
hello my programming is focused at the image processing library GD and FREE TYPE. I tried , amongst others, the script at this page : http://code.tutsplus.com/tutorials/build-your-own-captcha-and-contact-form--net-5362 but I cant get it working. I placed the true type font *.ttf file in the right directory but still get an error message saying: The image 'http://localhost/mydirectory/captcha.php' can't be displayed because it contains errors. (not sure this is the correct translation of the errormessage as it was displayed in my own language). I tried many things. like placing it in another directory. I checked phpinfo() to see if GD was installed which it was. Firefox gives an error message, IE and Chrome just dont show anything. This is the code: <?php session_start(); $string = ''; for ($i = 0; $i < 5; $i++) { // this numbers refer to numbers of the ascii table (lower case) $string .= chr(rand(97, 122)); } $_SESSION['rand_code'] = $string; // $dir = 'fonts/'; $dir = 'http://localhost/mydir/fonts/'; $image = imagecreatetruecolor(170, 60); $black = imagecolorallocate($image, 0, 0, 0); $color = imagecolorallocate($image, 200, 100, 90); // red $white = imagecolorallocate($image, 255, 255, 255); imagefilledrectangle($image,0,0,399,99,$white); // imagettftext ($image, 30, 0, 10, 40, $color, $dir."arial.ttf", $_SESSION['rand_code']); imagettftext ($image, 30, 0, 10, 40, $color, "arial.ttf", $_SESSION['rand_code']); header("Content-type: image/png"); imagepng($image); ?> What I want to know first is if I understand fully how it should be done. Maybe the tut I'm working with is not complete. Online I found a few topics with the same error report, they solved it by saving it as another file format (not utf-8). I would like to try that but dont know how. Notepad doesnt seem to have that feature of another file format like UTF-8 NO NOM. And besides that: WHY is file format so important? Please help !