Contents Previous Next

4.7.2 Verifying that the TTF fonts work

In order to get TTF fonts working with JpGraph you should first check that the following pure GD scripts work correctly. Please adjust the font path according to your installation.

 DEFINE ("TTF_DIR","/usr/X11R6/lib/X11/fonts/truetype/" ); 

$im imagecreatetruecolor (400 100); 
$black imagecolorallocate ($im 000 ); 
$white imagecolorallocate ($im 255255255 ); 

imagerectangle ($im,0, 0,399,99 ,$black); 
imagefilledrectangle ($im,0, 0,399,99 ,$white); 

imagettftext  ($im30 01040$blackTTF_DIR. "arial.ttf" "Hello World!"); 

header ("Content-type: image/png" ); 
imagepng ($im);

The above script assumes you have the GD2 library and will create an image with the classical "Hello World!" text printed in black.


Contents Previous Next