Jeg har selv det her eksempel der virker på windåse med PHP 4.2.2 op apache 1.3.26. Hugget fra PHP.Net og rettet lidt til...
<?PHP
$i_width = 700;
$i_height =300;
$string .= join(" ",$argv);
$pointsize = 25;
//
// Obviously, you need to specify fonts relevant on your system:
//
$fontfile="c:/windows/fonts/Arial.TTF";
//
// Create image:
//
$image = imagecreate($i_width, $i_height);
$backcolor = imagecolorallocate ($image, 128,128,85);
$forecolor = imagecolorallocate ($image, 255, 255, 255);
$forecolor2= imagecolorallocate ($image, 255,128,0);
//
// IMAGEFTBBOX()
//
// array imageftbbox ( int size, int angle, string font_file, string text [, array extrainfo])
//
// Well, this is only here as a reminder to myself on how to use it;
// $string_size is not actually used in this script:
//
$string_size = Imagettfbbox($pointsize, 0, $fontfile, $string);
$s_width = $string_size[4];
$s_height = $string_size[5];
//
// IMAGEFTTEXT()
//
// NOTE BENE: As far as I can tell, you CANNOT even pass the "array extrainfo" parameter
// and have anything work. I tested this using PHP 4.2.3, GD 2.0.1, and FREETYPE 2.1.2.
// (2002.09.13 -- or is it only because it was Friday the 13th that it didn't work?)
//
// array imagefttext ( resource image, int size, int angle, int x, int y, int col,
// string font_file, string text [, array extrainfo])
//
//
// Text at an angle:
//
ImagetTfText($image,$pointsize, 15, 5,125,$forecolor2,$fontfile,$string);
//
// Waterfall of point sizes to see what Freetype 2's autohinting looks like:
//
for($i=4;$i<=12;$i++){
ImagettfText($image,$i,0,10,(100+$i*14),$forecolor,$fontfile, $i . ". " . $string);
}
//
// Let's test some UTF-8!
//
//
// The free cyberbit font contains many scripts -- Download from
//
ftp://ftp8.netscape.com/pub/communicator/extras/fonts/windows///
//$fontfile="c:/psfonts/ttf/funky.ttf";
//
// This is a quotation from Mozi (Micius):
//
// My own approximate translation of this is:
//
// "Saintly men who are interested in governing everything under heaven
// must first understand the (seemingly spontaneous) origins of chaos."
//
$chinese_utf8="è–人以治天下爲事者也必知亂之所自起 -- 墨å
";
ImagettFText($image,$pointsize, 0, 10,45,$forecolor,$fontfile,$chinese_utf8);
//
// The following is the name of an Egyptian singer, Om Kolthoum:
// However, I haven't yet figured out how to render it right-to-left, so it is
// currently all messed up. I even tried adding the unicode RIGHT-TO-LEFT-MARK
// and RIGHT-TO-LEFT-EMBEDDING, but doesn't seem to work. If anyone knows how
// to get this to work, please let me know:
//
$arabic_utf8="This is incorrectly rendered L->R instead of R->L!: أم كلثوم";
ImagettFText($image,16, 0, 10,80,$forecolor,$fontfile,$arabic_utf8);
//
// In Thai, we need to see whether Freetype places vowels and tone marks
// in the right positions (usually over other letters, but some vowels go under or
// before other letters). This really depends on the font being designed right:
//
// The following is the name of a popular Thai singer:
//
$thai_utf8="ธงไชย à¹à¸¡à¹‡à¸„à¸à¸´à¸™à¹„ตย์";
ImagettFText($image,$pointsize, 0, 120,120,$forecolor,$fontfile,$thai_utf8);
Header ("Content-type: image/png");
ImagePNG ($image);
ImageDestroy ($image);
/*
include("functions.php")
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>
www.chanoandersen.dk </TITLE>
<?php include("meta.php");
</HEAD>
<BODY>
<?php
phpinfo();
</BODY>
</HTML>
*/
?>