21,886
社区成员
发帖
与我相关
我的任务
分享
<?php
// macleo 2008.9.20.Sat.
//������д....���ɵ�....ͨ��$font_spacing����
//defined ttf location and text will display
$font_path = "font/";
$font_name = $font_path."fzhc_GBK.ttf";
$font_size = 50;
$font_angle = 0 ;
$text = array("��","��","��","д","��","��","��","��");
$font_spacing = 25;//�ּ���������
$picname = "CanAdjust";
$position_x = 50;//first Character coordinate x;
$position_y = 70;//first Character coordinate x;
$font_shade_spacing_x = 3;
$font_shade_spacing_y = 3;
$im = imagecreatetruecolor(800, 100);
// colors
$white = imagecolorallocate($im, 0xff, 0xff, 0xff);
$grey = imagecolorallocate($im, 0x98, 0x98, 0x98);
$black = imagecolorallocate($im, 0x00, 0x00, 0x00);
imagefilledrectangle($im, 0, 0, 800, 100, $white);
// line
imageline ( $im, 799, 0, 0, 0, $black );//top
imageline ( $im, 799, 99, 0, 99, $black );//bottom
imageline ( $im, 0, 99, 0, 0, $black );//left
imageline ( $im, 799, 99, 799, 0, $black );//right
// get weight of every character of Chinese
$font_coordinate = imagettfbbox ( $font_size, $font_angle, $font_name, $text[0] );
$font_weight = $font_coordinate[2] - $font_coordinate[0];
$font_height = abs($font_coordinate[5]) - $font_coordinate[3];
//output text from array
for($count = 0 ; $count<=count($text) ; $count++)
{
$arr = imagettftext($im, $font_size, $font_angle , $position_x , $position_y, $grey, $font_name, $text[$count]);
imagettftext($im, $font_size, $font_angle , $position_x-$font_shade_spacing_x , $position_y-$font_shade_spacing_y, $black, $font_name, $text[$count]);
$position_x = $position_x + $font_weight + $font_spacing;
}
header('Content-disposition: inline; filename='.$picname.'.png');
imagepng($im);
ImageDestroy($im);
?>