imagecreate()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Slacker
Forum Newbie
Posts: 17
Joined: Thu Aug 12, 2004 9:19 pm

imagecreate()

Post 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.
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post 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
Slacker
Forum Newbie
Posts: 17
Joined: Thu Aug 12, 2004 9:19 pm

Post 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.
Post Reply