我目前生成了一个能生成透明的PNN图片
<?php 
// Set the content-type 
header ( 'Content-type: image/png' ); 
// Create the image 
$font_size = 18; //字体大小 14px
$text = '有朋自远方来。不亦乐呼'; 
// Replace path by your own font path 
//$text   =   iconv("gb2312","UTF-8",$text);
$font = 'D:\\ComsenzEXP\\wwwroot\\jquery\\fonts\\方正大黑繁体.ttf'; 
$font  =   iconv("UTF-8","gb2312",$font);
//imagepsslantfont ($font, 0.1 );
$fontarea = imagettfbbox($font_size,0,$font,$text); //确定会变化的字符串的位置$text_width = $fontarea[2]-$fontarea[0]+($font_size/3); //字符串文本框长度
$text_height = $fontarea[1]-$fontarea[7]+($font_size/3); ////字符串文本框高度
$im = imagecreate( $text_width , $text_height ); 
// Create some colors 
$white = imagecolorallocate($im, 255,255,255); //定义透明色
$red = imagecolorallocate ( $im , 255 , 0 , 0);  //文本色彩//imagecolortransparent($im,$white);
//imagefilledrectangle ( $im , 0 , 0 , 152 , 30 , $white ); //生成背景色
//ImageColorTransparent($img,$bgcolor); 
// The text to draw // Add some shadow to the text 
imagettftext ( $im , $font_size , 0 , 0, $text_height-($font_size/2.5) , $red , $font , $text ); 
imagecolortransparent($im,$white);
imagepng ( $im ); 
imagedestroy ($im); 
?> 字体加粗,斜体就没有这个选项。有谁知道吗。

解决方案 »

  1.   

    你在自已机器上找opentype.ttf的字体放到服务器目录,要open类型的,虽然都是ttf结尾,但有些不是open类型的,当然也并不是所有字体php都能用...
      

  2.   

    我有很多这种字体啊.中文汉仪的也有.我看别人几个网站就能实现,一个是ASPX开发的.一个我也不知道
    aspx.net http://www.kkdiy.com/diy/diy47.aspx
    还有一个卡当网
    http://www.kadang.com他们都能生成加粗和斜体的字.
      

  3.   

    难道这里都没有人会吗.PHP实现个这样的功能都这么难吗.