Page 1 of 1

imagecreate()

Posted: Sun Sep 05, 2004 3:43 pm
by Slacker
I'm working on something, and I need to know the built in fonts used for ImageCreate().

They are only listed as 1, 2, 3, 4, 5. Anything over 5 is a custom font file. I need to know which fonts are associated with 1-5. IE: Their TTF (True Type Font) counterparts.

Thanks.

Posted: Tue Sep 07, 2004 1:48 pm
by scorphus
The [php]imagestring[/php_man]() function's reference wrote:If font is 1, 2, 3, 4 or 5, a built-in font is used.
You could try

Code: Select all

imagettftext[/php_man]() to draw text with TTF fonts:

[php="[url=http://www.php.net/imagettftext#AEN47854]Example 1. imagettftext() example[/url]"]<?php
  header("Content-type: image/jpeg");
  $im = imagecreate(400, 30);
  $white = imagecolorallocate($im, 255, 255, 255);
  $black = imagecolorallocate($im, 0, 0, 0);
 
  // Replace path by your own font path
  imagettftext($im, 20, 0, 10, 20, $black, "/path/arial.ttf",
  "Testing... Omega: Ω");
  imagejpeg($im);
  imagedestroy($im);
?>
-- Scorphus

Posted: Wed Sep 08, 2004 7:24 am
by Slacker
Scorphus, currently I'm using imagettftext. I have yet to find an all around font though that works great with both dark and light backgrounds. On dark backgrounds the fonts I've found look great. On lighter ones, as you can see in my signature, they start to get hard to read.

I want to know what font the imagecreate is using so that I can find it's TTF file and use it in place of what I got now. As the default fonts they have look good in both dark and light backgrounds. I don't know if that's because of the font itself though or the way the pictures are drawn. IE: The imagestring draws a nicer picture than imagettftext does.