[Php] functiondraw_txt_to ($ card, $ pos, $ string) {$ font_colorimagecolorallocate ($ card, $ pos [& amp; #39; color & amp; #39;] [0], $ pos [& amp; #39; color & amp; #39;] [1], $ pos [&
[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