PHP文字生成 PHP文字生成

PHP文字生成

make.php?a=make&font={$k}&text={$text}&size={$size}&space={$space}
make.php?a=make&font={$k}&text={$text}&size={$size}&space={$space}&style=1
make.php?a=make&font={$k}&text={$text}&size={$size}&space={$space}&style=2
$style = @$_GET['style'];
$a = @$_GET['a'];
$font = @$_GET['font'];//字体名称
$space = @$_GET['space'];//间距
$text = @$_GET['text'];//文字
$size = @$_GET['size'];//文字
if(!$size){$size = 200;}
if(!$text){$text = "万之万印";}
$fnt = "fonts/$font";

$fnt2 = "fonts/{$font}_chang.ttf";

if($a=='down'){
$filename=$fnt;
if (file_exists($filename)) {
header('Content-Type: application/x-font-ttf');
header('Content-disposition:attachment;filename='.$font.'');
readfile($filename);
}else{echo "字体文件不存在";}
}

if($a=='make'){
$arr = mbstringtoarray($text,"UTF-8");
$arrnum=count($arr);//数量

   if(count($arr)<3){$arr[2]="之";$arr[3]="印";}
   if(count($arr)<4){$arr[3]="印";}
   
/***********/
//底图尺寸
$im=imagecreatefromjpeg("1.jpg");
//$im = imagecreate(600,600);//文字数量x135,高度150
//$white = imagecolorallocate($im,0xFF,0xFF,0xFF);
//imagecolortransparent($im,$white);  //imagecolortransparent() 设置具体某种颜色为透明色,若注释
$black = imagecolorallocate($im,0xFF,0x00,0x00);

if($style==1){
imagettftext($im,420,0,155,512,$black,"$fnt2",$arr[0]);
imagettftext($im,$size,0,35,267,$black,"$fnt",$arr[1]);
imagettftext($im,$size,0,35,537,$black,"$fnt",$arr[2]);
}elseif($style==2){
imagettftext($im,$size,0,297,267,$black,"$fnt",$arr[0]);
imagettftext($im,$size,0,297,537,$black,"$fnt",$arr[1]);
imagettftext($im,420,0,-120,512,$black,"$fnt2",$arr[2]);
}else{
imagettftext($im,$size,0,300,267,$black,$fnt,$arr[0]);
imagettftext($im,$size,0,300,537,$black,$fnt,$arr[1]);
imagettftext($im,$size,0,30,267,$black,$fnt,$arr[2]);
imagettftext($im,$size,0,30,537,$black,$fnt,$arr[3]);
}

header("Content-type:image/png");
//header('Content-disposition:attachment;filename='.$font.'.png');
imagepng($im);//输出
//imagepng($im,"font-face-thumbs/{$font}.png");//保存
//imagepng($im,$file);//保存
//readfile($filename);
//imagedestroy($im);
//readfile($im);
   }

/***************************
自定义函数:分割汉字统计数量
***************************/
  function mbstringtoarray($str,$charset) {
    $strlen=mb_strlen($str);
     while($strlen){
       $array[]=mb_substr($str,0,1,$charset);
       $str=mb_substr($str,1,$strlen,$charset);
       $strlen=mb_strlen($str);
     }
     return $array;
   }

评论 0

挤眼 亲亲 咆哮 开心 想想 可怜 糗大了 委屈 哈哈 小声点 右哼哼 左哼哼 疑问 坏笑 赚钱啦 悲伤 耍酷 勾引 厉害 握手 耶 嘻嘻 害羞 鼓掌 馋嘴 抓狂 抱抱 围观 威武 给力
提交评论

清空信息
关闭评论