[PHP]
function draw_txt_to ($card, $pos, $string)
{
$font _color = imagecolorallocate ($card, $pos [' Color '][0], $pos [' Color '][1], $pos [' Color '][2]);
$font _file = BasePath. /'. CFG (' TTF ');
$_string= ";
$__string= ";
for ($i =0; $i
{
$box =imagettfbbox ($pos [' FontSize '],0, $font _file,$_string);
$_string_length= $box [2]-$box [0];
$box =imagettfbbox ($pos [' FontSize '],0, $font _file,mb_substr ($string, $i, 1));
if ($_string_length+ $box [2]-$box [0]< $pos [' width '])
{
$_string.=mb_substr ($string, $i, 1);
}
Else
{
$__string.=$_string. " \ n ";
$_string=mb_substr ($string, $i, 1);
}
}
$__string.=$_string;
$box =imagettfbbox ($pos [' FontSize '],0, $font _file,mb_substr ($__string,0,1));
Imagettftext (
$card,
$pos [' FontSize '],
0,
$pos [' left '],
$pos [' Top ']+ ($box [3]-$box [7]),
$font _color,
$font _file,
$__string);
}
function draw_txt_to ($card, $pos, $string)
{
$font _color = imagecolorallocate ($card, $pos [' Color '][0], $pos [' Color '][1], $pos [' Color '][2]);
$font _file = BasePath. /'. CFG (' TTF ');
$_string= ";
$__string= ";
for ($i =0; $i<>
{
$box =imagettfbbox ($pos [' FontSize '],0, $font _file,$_string);
$_string_length= $box [2]-$box [0];
$box =imagettfbbox ($pos [' FontSize '],0, $font _file,mb_substr ($string, $i, 1));
if ($_string_length+ $box [2]-$box [0]< $pos [' width '])
{
$_string.=mb_substr ($string, $i, 1);
}
Else
{
$__string.=$_string. " \ n ";
$_string=mb_substr ($string, $i, 1);
}
}
$__string.=$_string;
$box =imagettfbbox ($pos [' FontSize '],0, $font _file,mb_substr ($__string,0,1));
Imagettftext (
$card,
$pos [' FontSize '],
0,www.2cto.com
$pos [' left '],
$pos [' Top ']+ ($box [3]-$box [7]),
$font _color,
$font _file,
$__string);
}
Author: Jiaochangyun
http://www.bkjia.com/PHPjc/478037.html www.bkjia.com true http://www.bkjia.com/PHPjc/478037.html techarticle [PHP] function draw_txt_to ($card, $pos, $string) {$font _color = imagecolorallocate ($card, $pos [color][0], $pos [ COLOR][1], $pos [color][2]); $font _file = basepath.../.cfg (TTF); $_string ...