Load a font in ttf file and draw a String with it in PHP

Description

The following code shows how to load a font in ttf file and draw a String with it.

Example


<?php// w  w  w  .  j a va 2  s  .  c o  m
header("Content-type: image/gif");

$image = imagecreate( 400, 200 );
$red = imagecolorallocate($image, 255,0,0);
$blue = imagecolorallocate($image, 0,0,255 );
$font = "ARIALBD.TTF";
imageTTFtext( $image, 50, 0, 20, 100, $blue, $font, "www.java2s.com" );
imagegif($image);
?>




















Home »
  PHP Tutorial »
    Image »




Color
Create
Font
Operation
Shape
Text